Data
400,000 rows, 330,473,472 bytes with indexes (heap 297,893,888 bytes):
create table docs (id bigint primary key, created_at timestamptz not null, status text not null,
title text not null, body text not null, meta jsonb not null, score double precision not null);
-- after select setseed(0.42):
with v as (select array_agg('w' || left(md5(i::text), 6) order by i) va from generate_series(1, 200) i)
insert into docs
select g, timestamptz '2026-01-01' + g * interval '37 seconds',
(array['draft','published','retired','rejected'])[1 + (g % 4)],
'Unit ' || g || ' ' || md5(g::text),
(select string_agg(v.va[1 + ((g::bigint * 7919 + k * 104729 + (random() * 13)::int) % 200)], ' ')
from generate_series(1, 60) k), -- 60 words from a 200-word vocabulary
jsonb_build_object('category', 'c' || (g % 40), 'tags', jsonb_build_array('t' || (g % 7), 't' || (g % 11)),
'price_micro', (g % 1000) * 10, 'lang', case when g % 3 = 0 then 'ko' else 'en' end),
random() * 100
from generate_series(1, 400000) g, v;
create index on docs (created_at); create index on docs (status, score); vacuum analyze docs;
Commands
- Dump, 5 times per method:
pg_dump -Fc --compress=<method> -f /tmp/d.<method> postgres - Restore, 5 times per method:
dropdb --if-exists r; createdb r; pg_restore -d r /tmp/d.<method> (only the pg_restore is timed); row count checked after each (400000). - Timing:
date +%s%N around the command.
Raw values (ms)
dump none 3923 4591 3827 3781 3474 dump gzip:1 2677 2545 2490 2496 2500 dump gzip:6 5643 5652 5525 5557 5521 dump gzip:9 6334 6348 6276 6244 6264 dump lz4 2160 1881 1886 1888 1884 dump zstd:1 1867 1748 1664 1672 1705 dump zstd:3 2080 2024 1962 1973 1979 dump zstd:9 5283 5214 5306 5237 5223 restore none 9493 6411 5032 4711 4646 restore gzip:6 4749 4900 4765 5070 5795 restore lz4 6241 5962 6105 4768 4589 restore zstd:3 5360 5779 5942 6079 6940
Limits
- Shared cloud VM with 2 vCPU: neighbours add noise, most visible in restore and in the uncompressed dump (disk-bound). The compressed dumps are CPU-bound and were tighter (every run within 15% of its median, most within 3%).
- Synthetic, very compressible text (a 200-word vocabulary gives 4.4× with gzip). Real tables with more entropy, or with large already-compressed (TOASTed) values, compress less; the absolute sizes will not transfer, the ordering of methods probably will.
- One table, custom format (-Fc), single-threaded dump. Directory format with
-j and parallel restore were not measured. - The client and server shared the same 2 CPUs, so compression competed with the server sending rows. A dump taken from another machine would behave differently.
- PostgreSQL 16.15 only;
--compress=lz4|zstd needs a pg_dump built with those libraries (the Debian/PGDG build in this image is).