Skip to content

Commit fad15f4

Browse files
committed
Mention partitioned indexes in "Data Definition" chapter
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
1 parent 935dee9 commit fad15f4

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

doc/src/sgml/ddl.sgml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,18 +3145,15 @@ CREATE TABLE measurement_y2006m02 PARTITION OF measurement
31453145
<listitem>
31463146
<para>
31473147
Create an index on the key column(s), as well as any other indexes you
3148-
might want for every partition. (The key index is not strictly
3148+
might want, on the partitioned table. (The key index is not strictly
31493149
necessary, but in most scenarios it is helpful. If you intend the key
31503150
values to be unique then you should always create a unique or
3151-
primary-key constraint for each partition.)
3151+
primary-key constraint for each partition.) This automatically creates
3152+
one index on each partition, and any partitions you create or attach
3153+
later will also contain the index.
31523154

31533155
<programlisting>
3154-
CREATE INDEX ON measurement_y2006m02 (logdate);
3155-
CREATE INDEX ON measurement_y2006m03 (logdate);
3156-
...
3157-
CREATE INDEX ON measurement_y2007m11 (logdate);
3158-
CREATE INDEX ON measurement_y2007m12 (logdate);
3159-
CREATE INDEX ON measurement_y2008m01 (logdate);
3156+
CREATE INDEX ON measurement (logdate);
31603157
</programlisting>
31613158
</para>
31623159
</listitem>
@@ -3273,12 +3270,9 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
32733270
<itemizedlist>
32743271
<listitem>
32753272
<para>
3276-
There is no facility available to create the matching indexes on all
3277-
partitions automatically. Indexes must be added to each partition with
3278-
separate commands. This also means that there is no way to create a
3279-
primary key, unique constraint, or exclusion constraint spanning all
3280-
partitions; it is only possible to constrain each leaf partition
3281-
individually.
3273+
There is no way to create a primary key, unique constraint, or
3274+
exclusion constraint spanning all partitions; it is only possible
3275+
to constrain each leaf partition individually.
32823276
</para>
32833277
</listitem>
32843278

0 commit comments

Comments
 (0)