Mention partitioned indexes in "Data Definition" chapter
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 10 Feb 2018 13:01:37 +0000 (10:01 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 10 Feb 2018 13:06:01 +0000 (10:06 -0300)
We can now create indexes more easily than before, so update this
chapter to use the simpler instructions.

After an idea of Amit Langote.  I (Álvaro) opted to do more invasive
surgery and remove the previous suggestion to create per-partition
indexes, which his patch left in place.

Discussion: https://postgr.es/m/eafaaeb1-f0fd-d010-dd45-07db0300f645@lab.ntt.co.jp
Author: Amit Langote, Álvaro Herrera

doc/src/sgml/ddl.sgml

index 1e1f3428a6ba0441b356f8fd89dcbea4b9dfc6ec..bee1ebd7dbc2a33090d7a6bc22bba77954d9a972 100644 (file)
@@ -3145,18 +3145,15 @@ CREATE TABLE measurement_y2006m02 PARTITION OF measurement
      <listitem>
       <para>
        Create an index on the key column(s), as well as any other indexes you
-       might want for every partition.  (The key index is not strictly
+       might want, on the partitioned table. (The key index is not strictly
        necessary, but in most scenarios it is helpful.  If you intend the key
        values to be unique then you should always create a unique or
-       primary-key constraint for each partition.)
+       primary-key constraint for each partition.)  This automatically creates
+       one index on each partition, and any partitions you create or attach
+       later will also contain the index.
 
 <programlisting>
-CREATE INDEX ON measurement_y2006m02 (logdate);
-CREATE INDEX ON measurement_y2006m03 (logdate);
-...
-CREATE INDEX ON measurement_y2007m11 (logdate);
-CREATE INDEX ON measurement_y2007m12 (logdate);
-CREATE INDEX ON measurement_y2008m01 (logdate);
+CREATE INDEX ON measurement (logdate);
 </programlisting>
       </para>
      </listitem>
@@ -3273,12 +3270,9 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
     <itemizedlist>
      <listitem>
       <para>
-       There is no facility available to create the matching indexes on all
-       partitions automatically.  Indexes must be added to each partition with
-       separate commands.  This also means that there is no way to create a
-       primary key, unique constraint, or exclusion constraint spanning all
-       partitions; it is only possible to constrain each leaf partition
-       individually.
+       There is no way to create a primary key, unique constraint, or
+       exclusion constraint spanning all partitions; it is only possible
+       to constrain each leaf partition individually.
       </para>
      </listitem>