Skip to content

Commit 6c0398a

Browse files
committed
Add some notes about how pg_dump relates to the practices recommended
under 'Populating a Database'.
1 parent 9a412be commit 6c0398a

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

doc/src/sgml/perform.sgml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.52 2005/09/02 00:57:57 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.53 2005/09/02 03:19:53 tgl Exp $
33
-->
44

55
<chapter id="performance-tips">
@@ -878,6 +878,54 @@ SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
878878
statistics.
879879
</para>
880880
</sect2>
881+
882+
<sect2 id="populate-pg-dump">
883+
<title>Some Notes About <application>pg_dump</></title>
884+
885+
<para>
886+
Dump scripts generated by <application>pg_dump</> automatically apply
887+
several, but not all, of the above guidelines. To reload a
888+
<application>pg_dump</> dump as quickly as possible, you need to
889+
do a few extra things manually. (Note that these points apply while
890+
<emphasis>restoring</> a dump, not while <emphasis>creating</> it.
891+
The same points apply when using <application>pg_restore</> to load
892+
from a <application>pg_dump</> archive file.)
893+
</para>
894+
895+
<para>
896+
By default, <application>pg_dump</> uses <command>COPY</>, and when
897+
it is generating a complete schema-and-data dump, it is careful to
898+
load data before creating indexes and foreign keys. So in this case
899+
the first several guidelines are handled automatically. What is left
900+
for you to do is to set appropriate (i.e., larger than normal) values
901+
for <varname>maintenance_work_mem</varname> and
902+
<varname>checkpoint_segments</varname> before loading the dump script,
903+
and then to run <command>ANALYZE</> afterwards.
904+
</para>
905+
906+
<para>
907+
A data-only dump will still use <command>COPY</>, but it does not
908+
drop or recreate indexes, and it does not normally touch foreign
909+
keys.
910+
911+
<footnote>
912+
<para>
913+
You can get the effect of disabling foreign keys by using
914+
the <option>-X disable-triggers</> option &mdash; but realize that
915+
that eliminates, rather than just postponing, foreign key
916+
validation, and so it is possible to insert bad data if you use it.
917+
</para>
918+
</footnote>
919+
920+
So when loading a data-only dump, it is up to you to drop and recreate
921+
indexes and foreign keys if you wish to use those techniques.
922+
It's still useful to increase <varname>checkpoint_segments</varname>
923+
while loading the data, but don't bother increasing
924+
<varname>maintenance_work_mem</varname>; rather, you'd do that while
925+
manually recreating indexes and foreign keys afterwards.
926+
And don't forget to <command>ANALYZE</> when you're done.
927+
</para>
928+
</sect2>
881929
</sect1>
882930

883931
</chapter>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy