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

Commitea88133

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 parent3534fa2 commitea88133

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
@@ -3952,14 +3952,14 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
39523952
<para>
39533953
Before running the <command>ATTACH PARTITION</command> command, it is
39543954
recommended to create a <literal>CHECK</literal> constraint on the table to
3955-
be attacheddescribing the desired partition constraint. That way,
3955+
be attachedmatching the desired partition constraint. That way,
39563956
the system will be able to skip the scan to validate the implicit
3957-
partition constraint. Withoutsuch a constraint, the table will be
3958-
scanned to validate the partition constraint while holding an
3959-
<literal>ACCESS EXCLUSIVE</literal> lock on that partition
3957+
partition constraint. Withoutthe <literal>CHECK</literal> constraint,
3958+
the table will bescanned to validate the partition constraint while
3959+
holding an<literal>ACCESS EXCLUSIVE</literal> lock on that partition
39603960
and a <literal>SHARE UPDATE EXCLUSIVE</literal> lock on the parent table.
3961-
One maythendrop theconstraint after <command>ATTACH PARTITION</command>
3962-
is finished, because itisno longer necessary.
3961+
It maybe desired todrop theredundant <literal>CHECK</literal> constraint
3962+
after <command>ATTACH PARTITION</command>isfinished.
39633963
</para>
39643964

39653965
<para>

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
841841
or as a default partition by using <literal>DEFAULT</literal>.
842842
For each index in the target table, a corresponding
843843
one will be created in the attached table; or, if an equivalent
844-
index already exists, will be attached to the target table's index,
844+
index already exists,itwill be attached to the target table's index,
845845
as if <command>ALTER INDEX ATTACH PARTITION</command> had been executed.
846846
Note that if the existing table is a foreign table, it is currently not
847847
allowed to attach the table as a partition of the target table if there
@@ -864,23 +864,24 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
864864
already exist.
865865
If any of the <literal>CHECK</literal> constraints of the table being
866866
attached is marked <literal>NO INHERIT</literal>, the command will fail;
867-
sucha constraintmust be recreated without the <literal>NO INHERIT</literal>
868-
clause.
867+
suchconstraintsmust be recreated without the
868+
<literal>NO INHERIT</literal>clause.
869869
</para>
870870

871871
<para>
872872
If the new partition is a regular table, a full table scan is performed
873-
to check that no existing row in the table violates the partition
874-
constraint. It is possible to avoid this scan by adding a valid
875-
<literal>CHECK</literal> constraint to the table that would allow only
876-
the rows satisfying the desired partition constraint before running this
877-
command. It will be determined using such a constraint that the table
878-
need not be scanned to validate the partition constraint. This does not
879-
work, however, if any of the partition keys is an expression and the
880-
partition does not accept <literal>NULL</literal> values. If attaching
881-
a list partition that will not accept <literal>NULL</literal> values,
882-
also add <literal>NOT NULL</literal> constraint to the partition key
883-
column, unless it's an expression.
873+
to check that existing rows in the table do not violate the partition
874+
constraint. It is possible to avoid this scan by adding a valid
875+
<literal>CHECK</literal> constraint to the table that allows only
876+
rows satisfying the desired partition constraint before running this
877+
command. The <literal>CHECK</literal> constraint will be used to
878+
determine that the table need not be scanned to validate the partition
879+
constraint. This does not work, however, if any of the partition keys
880+
is an expression and the partition does not accept
881+
<literal>NULL</literal> values. If attaching a list partition that will
882+
not accept <literal>NULL</literal> values, also add
883+
<literal>NOT NULL</literal> constraint to the partition key column,
884+
unless it's an expression.
884885
</para>
885886

886887
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp