snippetsqlMinor
Does my choice of pg_dump format impact restore speed?
Viewed 0 times
formatpg_dumpimpactchoicedoesspeedrestore
Problem
According to the docs for my version of Postgres (8.4.2), pg_dump can "output in script or archive file formats." The script-formatted dump (4GB) takes 1.5 hours to restore, and I'm wondering if the archive format is any faster.
My script-formatted dump is using COPY commands, by the way, so it's not like I'm doing one insert at a time.
Thanks in advance.
My script-formatted dump is using COPY commands, by the way, so it's not like I'm doing one insert at a time.
Thanks in advance.
Solution
Archive format has small impact on restore time.
That's because actually, when you restore from plain format, it is equivalent to:
and when you restore from "compressed" format, it is equivalent to:
, and the cost of decompression with pg_restore is usually negligible, compared to write-intensive COPY/CREATE INDEX commands which happen during restore.
For large dumps, restoring from compressed dumps may be a bit faster (less disk reads).
It might be even faster with
For more details about
That's because actually, when you restore from plain format, it is equivalent to:
cat backup.file | psql emptydband when you restore from "compressed" format, it is equivalent to:
pg_restore backup.file | psql emptydb, and the cost of decompression with pg_restore is usually negligible, compared to write-intensive COPY/CREATE INDEX commands which happen during restore.
For large dumps, restoring from compressed dumps may be a bit faster (less disk reads).
It might be even faster with
-j (--jobs) option. It can be used only with "compressed" format, and it allows paralell restore with N concurrent jobs (sessions).For more details about
-j option, see http://www.postgresql.org/docs/8.4/static/app-pgrestore.html. Example:pg_restore -j 4 -d emptydb backup.fileCode Snippets
cat backup.file | psql emptydbpg_restore backup.file | psql emptydbpg_restore -j 4 -d emptydb backup.fileContext
StackExchange Database Administrators Q#8855, answer score: 9
Revisions (0)
No revisions yet.