Re: Does pg_dump custom format only compress the table data?

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Does pg_dump custom format only compress the table data?
Date: 2026-02-03 16:33:04
Message-ID: CANzqJaBj0rjgXi2cX+imxGCRB02afDK7=PkrOaR6xg+iVm7qSg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, Feb 3, 2026 at 11:16 AM Ron Johnson <ronljohnsonjr(at)gmail(dot)com> wrote:

> On Tue, Feb 3, 2026 at 7:48 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
> wrote:
>
>> On Tue, 2026-02-03 at 08:51 +0100, Holger Jakobs wrote:
>> > Am 03.02.26 um 07:06 schrieb Laurenz Albe:
>> > > On Mon, 2026-02-02 at 10:55 -0500, Ron Johnson wrote:
>> > > > Out of curiosity, I opened that dump file in vim, and saw not only
>> DDL strings but cleartext table data.
>> > > >
>> > > > Why isn't it compressed?
>> > > Are your DDL statement large enough that you would expect that
>> compressing
>> > > them would offer any real advantage?
>> >
>> > That wasn't the question. It was about why table DATA aren't
>> compressed,
>> > but in clear text.
>>
>> Ah, I see.
>>
>> By default, you wouldn't see any table data, because they get compressed.
>>
>> If a custom format dump is not compressed, the reason could be:
>>
>> - PostgreSQL was built without support for compression (--without-zlib)
>>
>> - pg_dump was called with --compress=0
>>
>
> I always install RPMs from postgresql.org, and in this case specified
> --compress=zstd:long.
>
> $ psql -V
> psql (PostgreSQL) 17.7
>
> dba=# insert into do_not_delete (node_name) values ('foo');
> INSERT 0 1
> dba=# insert into do_not_delete (node_name) values ('bar');
> INSERT 0 1
> dba=# insert into do_not_delete (node_name) values ('blarge');
> INSERT 0 1
> dba=#
>
> $ pg_dump -V
> pg_dump (PostgreSQL) 17.7
>
> db=dba
> $ pg_dump -Fc --compress=zstd:long -v -d${db} -f ${db}.dump 2> ${db}.log
> $ dir ${db}.dump
> -rw-r--r-- 1 postgres postgres 2205102870 2026-02-03 11:07:34 dba.dump
>
> $ strings ${db}.dump | grep -E 'foo|bar|blarge'
> foo \N
> bar \N
> blarge \N
> \Afoo
> barYD
> [snip]
>

I tested more. The default gzip compression does in fact compress
everything. This must be a quirk of zstd.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Ribe 2026-02-04 16:09:25 row from index tuple
Previous Message Ron Johnson 2026-02-03 16:16:30 Re: Does pg_dump custom format only compress the table data?