Commit ad4fd77a authored by Tom Lane's avatar Tom Lane

Restructure performance tips into a single chapter ('populating a

database' was way too small to make a chapter).  Add a section about
using JOIN syntax to direct the planner.
parent 85934d1b
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/filelist.sgml,v 1.2 2000/12/14 22:30:56 petere Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/filelist.sgml,v 1.3 2000/12/16 02:29:36 tgl Exp $ -->
<!entity about SYSTEM "about.sgml">
<!entity history SYSTEM "history.sgml">
......@@ -26,11 +26,10 @@
<!entity inherit SYSTEM "inherit.sgml">
<!entity manage SYSTEM "manage.sgml">
<!entity mvcc SYSTEM "mvcc.sgml">
<!entity plan SYSTEM "plan.sgml">
<!entity perform SYSTEM "perform.sgml">
<!entity plperl SYSTEM "plperl.sgml">
<!entity plsql SYSTEM "plsql.sgml">
<!entity pltcl SYSTEM "pltcl.sgml">
<!entity populate SYSTEM "populate.sgml">
<!entity psql SYSTEM "psql.sgml">
<!entity query-ug SYSTEM "query-ug.sgml">
<!entity storage SYSTEM "storage.sgml">
......
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/populate.sgml,v 2.3 2000/09/29 20:21:34 petere Exp $
-->
<chapter id="populate">
<title>Populating a Database</title>
<note>
<title>Author</title>
<para>
Written by Tom Lane, from an e-mail message dated 1999-12-05.
</para>
</note>
<para>
One may need to do a large number of table insertions when first
populating a database. Here are some tips and techniques for making that as
efficient as possible.
</para>
<sect1 id="disable-autocommit">
<title>Disable Auto-commit</title>
<para>
Turn off auto-commit and just do one commit at
the end. Otherwise <productname>Postgres</productname> is doing a
lot of work for each record
added. In general when you are doing bulk inserts, you want
to turn off some of the database features to gain speed.
</para>
</sect1>
<sect1 id="populate-copy-from">
<title>Use COPY FROM</title>
<para>
Use <command>COPY FROM STDIN</command> to load all the records in one
command, instead
of a series of INSERT commands. This reduces parsing, planning, etc
overhead a great deal. If you do this then it's not necessary to fool
around with autocommit.
</para>
</sect1>
<sect1 id="populate-rm-indices">
<title>Remove Indices</title>
<para>
If you are loading a freshly created table, the fastest way is to
create the table, bulk-load with COPY, then create any indexes needed
for the table. Creating an index on pre-existing data is quicker than
updating it incrementally as each record is loaded.
</para>
<para>
If you are augmenting an existing table, you can <command>DROP
INDEX</command>, load the table, then recreate the index. Of
course, the database performance for other users may be adversely
affected during the time that the index is missing.
</para>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode:sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:("/usr/lib/sgml/catalog")
sgml-local-ecat-files:nil
End:
-->
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.21 2000/12/14 22:30:56 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.22 2000/12/16 02:29:36 tgl Exp $
-->
<book id="user">
......@@ -57,8 +57,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/user.sgml,v 1.21 2000/12/14 22:30:56
&environ;
&manage;
&storage;
&plan;
&populate
&perform;
<!-- appendices -->
......
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