Commit 6c0398a7 authored by Tom Lane's avatar Tom Lane

Add some notes about how pg_dump relates to the practices recommended

under 'Populating a Database'.
parent 9a412be5
<!--
$PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.52 2005/09/02 00:57:57 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.53 2005/09/02 03:19:53 tgl Exp $
-->
<chapter id="performance-tips">
......@@ -878,6 +878,54 @@ SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
statistics.
</para>
</sect2>
<sect2 id="populate-pg-dump">
<title>Some Notes About <application>pg_dump</></title>
<para>
Dump scripts generated by <application>pg_dump</> automatically apply
several, but not all, of the above guidelines. To reload a
<application>pg_dump</> dump as quickly as possible, you need to
do a few extra things manually. (Note that these points apply while
<emphasis>restoring</> a dump, not while <emphasis>creating</> it.
The same points apply when using <application>pg_restore</> to load
from a <application>pg_dump</> archive file.)
</para>
<para>
By default, <application>pg_dump</> uses <command>COPY</>, and when
it is generating a complete schema-and-data dump, it is careful to
load data before creating indexes and foreign keys. So in this case
the first several guidelines are handled automatically. What is left
for you to do is to set appropriate (i.e., larger than normal) values
for <varname>maintenance_work_mem</varname> and
<varname>checkpoint_segments</varname> before loading the dump script,
and then to run <command>ANALYZE</> afterwards.
</para>
<para>
A data-only dump will still use <command>COPY</>, but it does not
drop or recreate indexes, and it does not normally touch foreign
keys.
<footnote>
<para>
You can get the effect of disabling foreign keys by using
the <option>-X disable-triggers</> option &mdash; but realize that
that eliminates, rather than just postponing, foreign key
validation, and so it is possible to insert bad data if you use it.
</para>
</footnote>
So when loading a data-only dump, it is up to you to drop and recreate
indexes and foreign keys if you wish to use those techniques.
It's still useful to increase <varname>checkpoint_segments</varname>
while loading the data, but don't bother increasing
<varname>maintenance_work_mem</varname>; rather, you'd do that while
manually recreating indexes and foreign keys afterwards.
And don't forget to <command>ANALYZE</> when you're done.
</para>
</sect2>
</sect1>
</chapter>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment