Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f8ff09

Browse files
committed
Doc: Improve description around ALTER TABLE ATTACH PARTITION
This clarifies more how to use and how to take advantage of constraintswhen attaching a new partition.Author: Justin PryzbyReviewed-by: Amit Langote, Álvaro Herrera, Michael PaquierDiscussion:https://postgr.es/m/20191028001207.GB23808@telsasoft.comBackpatch-through: 10
1 parent078f5bc commit8f8ff09

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,13 +3336,13 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
33363336
<para>
33373337
Before running the <command>ATTACH PARTITION</command> command, it is
33383338
recommended to create a <literal>CHECK</literal> constraint on the table to
3339-
be attacheddescribing the desired partition constraint. That way,
3339+
be attachedmatching the desired partition constraint. That way,
33403340
the system will be able to skip the scan to validate the implicit
3341-
partition constraint. Withoutsuch a constraint, the table will be
3342-
scanned to validate the partition constraint while holding an
3343-
<literal>ACCESS EXCLUSIVE</literal> lock on the parent table.
3344-
One maythendrop theconstraint after <command>ATTACH PARTITION</command>
3345-
is finished, because itisno longer necessary.
3341+
partition constraint. Withoutthe <literal>CHECK</literal> constraint,
3342+
the table will bescanned to validate the partition constraint while
3343+
holding an<literal>ACCESS EXCLUSIVE</literal> lock on the parent table.
3344+
It maybe desired todrop theredundant <literal>CHECK</literal> constraint
3345+
after <command>ATTACH PARTITION</command>isfinished.
33463346
</para>
33473347

33483348
<para>

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
857857
or as a default partition by using <literal>DEFAULT</literal>.
858858
For each index in the target table, a corresponding
859859
one will be created in the attached table; or, if an equivalent
860-
index already exists, will be attached to the target table's index,
860+
index already exists,itwill be attached to the target table's index,
861861
as if <command>ALTER INDEX ATTACH PARTITION</command> had been executed.
862862
Note that if the existing table is a foreign table, it is currently not
863863
allowed to attach the table as a partition of the target table if there
@@ -880,23 +880,24 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
880880
already exist.
881881
If any of the <literal>CHECK</literal> constraints of the table being
882882
attached is marked <literal>NO INHERIT</literal>, the command will fail;
883-
sucha constraintmust be recreated without the <literal>NO INHERIT</literal>
884-
clause.
883+
suchconstraintsmust be recreated without the
884+
<literal>NO INHERIT</literal>clause.
885885
</para>
886886

887887
<para>
888888
If the new partition is a regular table, a full table scan is performed
889-
to check that no existing row in the table violates the partition
890-
constraint. It is possible to avoid this scan by adding a valid
891-
<literal>CHECK</literal> constraint to the table that would allow only
892-
the rows satisfying the desired partition constraint before running this
893-
command. It will be determined using such a constraint that the table
894-
need not be scanned to validate the partition constraint. This does not
895-
work, however, if any of the partition keys is an expression and the
896-
partition does not accept <literal>NULL</literal> values. If attaching
897-
a list partition that will not accept <literal>NULL</literal> values,
898-
also add <literal>NOT NULL</literal> constraint to the partition key
899-
column, unless it's an expression.
889+
to check that existing rows in the table do not violate the partition
890+
constraint. It is possible to avoid this scan by adding a valid
891+
<literal>CHECK</literal> constraint to the table that allows only
892+
rows satisfying the desired partition constraint before running this
893+
command. The <literal>CHECK</literal> constraint will be used to
894+
determine that the table need not be scanned to validate the partition
895+
constraint. This does not work, however, if any of the partition keys
896+
is an expression and the partition does not accept
897+
<literal>NULL</literal> values. If attaching a list partition that will
898+
not accept <literal>NULL</literal> values, also add
899+
<literal>NOT NULL</literal> constraint to the partition key column,
900+
unless it's an expression.
900901
</para>
901902

902903
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp