You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
When CREATE INDEX is run on a partitioned table, create catalog entriesfor an index on the partitioned table (which is just a placeholder sincethe table proper has no data of its own), and recurse to create actualindexes on the existing partitions; create them in future partitionsalso.As a convenience gadget, if the new index definition matches someexisting index in partitions, these are picked up and used instead ofcreating new ones. Whichever way these indexes come about, they becomeattached to the index on the parent table and are dropped alongside it,and cannot be dropped on isolation unless they are detached first.To support pg_dump'ing these indexes, add commands CREATE INDEX ON ONLY <table>(which creates the index on the parent partitioned table, withoutrecursing) and ALTER INDEX ATTACH PARTITION(which is used after the indexes have been created individually on eachpartition, to attach them to the parent index). These reconstruct priordatabase state exactly.Reviewed-by: (in alphabetical order) Peter Eisentraut, Robert Haas, AmitLangote, Jesper Pedersen, Simon Riggs, David RowleyDiscussion:https://postgr.es/m/20171113170646.gzweigyrgg6pwsg4@alvherre.pgsql
Copy file name to clipboardExpand all lines: doc/src/sgml/ref/alter_index.sgml
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ PostgreSQL documentation
23
23
<synopsis>
24
24
ALTER INDEX [ IF EXISTS ] <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
25
25
ALTER INDEX [ IF EXISTS ] <replaceable class="parameter">name</replaceable> SET TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
26
+
ALTER INDEX <replaceable class="parameter">name</replaceable> ATTACH PARTITION <replaceable class="parameter">index_name</replaceable>
26
27
ALTER INDEX <replaceable class="parameter">name</replaceable> DEPENDS ON EXTENSION <replaceable class="parameter">extension_name</replaceable>
27
28
ALTER INDEX [ IF EXISTS ] <replaceable class="parameter">name</replaceable> SET ( <replaceable class="parameter">storage_parameter</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
28
29
ALTER INDEX [ IF EXISTS ] <replaceable class="parameter">name</replaceable> RESET ( <replaceable class="parameter">storage_parameter</replaceable> [, ... ] )
@@ -75,6 +76,19 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="parameter">name</replaceable>
75
76
</listitem>
76
77
</varlistentry>
77
78
79
+
<varlistentry>
80
+
<term><literal>ATTACH PARTITION</literal></term>
81
+
<listitem>
82
+
<para>
83
+
Causes the named index to become attached to the altered index.
84
+
The named index must be on a partition of the table containing the
85
+
index being altered, and have an equivalent definition. An attached
86
+
index cannot be dropped by itself, and will automatically be dropped
87
+
if its parent index is dropped.
88
+
</para>
89
+
</listitem>
90
+
</varlistentry>
91
+
78
92
<varlistentry>
79
93
<term><literal>DEPENDS ON EXTENSION</literal></term>
Copy file name to clipboardExpand all lines: doc/src/sgml/ref/create_index.sgml
+32-1Lines changed: 32 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ PostgreSQL documentation
21
21
22
22
<refsynopsisdiv>
23
23
<synopsis>
24
-
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class="parameter">name</replaceable> ] ON <replaceable class="parameter">table_name</replaceable> [ USING <replaceable class="parameter">method</replaceable> ]
24
+
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class="parameter">name</replaceable> ] ON[ ONLY ]<replaceable class="parameter">table_name</replaceable> [ USING <replaceable class="parameter">method</replaceable> ]