mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add some notes about how pg_dump relates to the practices recommended
under 'Populating a Database'.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$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 — 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>
|
||||
|
Reference in New Issue
Block a user