Re: pg_dump slower than pg_restore

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: David Wall <d(dot)wall(at)computer(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: pg_dump slower than pg_restore
Date: 2014-07-04 18:55:19
Message-ID: 53B6F897.3090007@boscorama.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/03/14 22:51, David Wall wrote:
>
> On 7/3/2014 11:47 AM, Eduardo Morras wrote:
>> No, there's nothing wrong. All transparent compressed objects stored
>> in database, toast, lo, etc.. is transparently decompressed while
>> pg_dump access them and then you gzip it again. I don't know why it
>> doesn't dump the compressed data directly.
>
> That sounds odd, but if pg_dump decompresses the large objects and then
> I gzip them on backup, doesn't the same more or less happen in reverse
> when I pg_restore them? I mean, I gunzip the backup and then pg_restore
> must compress the large objects when it writes them back.

I believe there is a little confusion here. (If not, I apologize in
advance :-) ).

There are at least 3 forms of (de)compression going on here:
1) Application level: The data itself is presented to the
application in a compressed format (image file, etc.) or
it is compressed by the application prior to presentation to PG.
The fact that this data is compressed is not relevant to the
following;

2) PG server-side: Automated TOAST (de)compression which may or may
not be enabled for a table/column.

3) Dump/restore/tools: the pg dump/restore and any tools you
use to (de)compress the DB backup. Without due care this can
end up in multiple attempts to (de)compress the same file, as
we've seen. :-)

Regardless of what happens in 2) & 3) the application-level compression
state in 1) will not be affected.

Thus a blob that represents a gzip'd file presented to PG in 1) will
remain compressed through all 3 stages. It is *not* auto-magically
uncompressed at any stage.

I believe Eduardo was referring to 2) which, because it is an
automated, transparent, server-side operation needs to be performed
even as part of a dump/restore.

HTH,
Bosco.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2014-07-04 20:32:49 Query "top 10 and others"
Previous Message François Beausoleil 2014-07-04 18:42:49 index contains unexpected zero page at block error