Skip to content

Commit ff21323

Browse files
committed
Add a note to the CREATE INDEX reference page about the impact of
maintenance_work_mem and effective_cache_size on index creation speed.
1 parent 787eba7 commit ff21323

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

doc/src/sgml/ref/create_index.sgml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.66 2007/11/26 21:36:33 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.67 2008/03/16 23:57:51 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -32,7 +32,7 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] <replaceable class="parameter">name</re
3232
<title>Description</title>
3333

3434
<para>
35-
<command>CREATE INDEX</command> constructs an index <replaceable
35+
<command>CREATE INDEX</command> constructs an index named <replaceable
3636
class="parameter">name</replaceable> on the specified table.
3737
Indexes are primarily used to enhance database performance (though
3838
inappropriate use can result in slower performance).
@@ -433,6 +433,23 @@ Indexes:
433433
sort high</>, in queries that depend on indexes to avoid sorting steps.
434434
</para>
435435

436+
<para>
437+
For most index methods, the speed of creating an index is
438+
dependent on the setting of <xref linkend="guc-maintenance-work-mem">.
439+
Larger values will reduce the time needed for index creation, so long
440+
as you don't make it larger than the amount of memory really available,
441+
which would drive the machine into swapping. For hash indexes, the
442+
value of <xref linkend="guc-effective-cache-size"> is also relevant to
443+
index creation time: <productname>PostgreSQL</productname> will use one
444+
of two different hash index creation methods depending on whether the
445+
estimated index size is more or less than <varname>effective_cache_size</>.
446+
For best results, make sure that this parameter is also set to something
447+
reflective of available memory, and be careful that the sum of
448+
<varname>maintenance_work_mem</> and <varname>effective_cache_size</> is
449+
less than the machine's RAM less whatever space is needed by other
450+
programs.
451+
</para>
452+
436453
<para>
437454
Use <xref linkend="sql-dropindex" endterm="sql-dropindex-title">
438455
to remove an index.

0 commit comments

Comments
 (0)