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

Commitf5efc93

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 parentee8b95f commitf5efc93

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,13 +3308,13 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
33083308
<para>
33093309
Before running the <command>ATTACH PARTITION</> command, it is
33103310
recommended to create a <literal>CHECK</> constraint on the table to
3311-
be attacheddescribing the desired partition constraint. That way,
3311+
be attachedmatching the desired partition constraint. That way,
33123312
the system will be able to skip the scan to validate the implicit
3313-
partition constraint. Withoutsuch a constraint, the table will be
3314-
scanned to validate the partition constraint while holding an
3315-
<literal>ACCESS EXCLUSIVE</literal> lock on the parent table.
3316-
One maythendrop theconstraint after <command>ATTACH PARTITION</>
3317-
is finished, because itisno longer necessary.
3313+
partition constraint. Withoutthe <literal>CHECK</> constraint,
3314+
the table will bescanned to validate the partition constraint while
3315+
holding an<literal>ACCESS EXCLUSIVE</literal> lock on the parent table.
3316+
It maybe desired todrop theredundant <literal>CHECK</> constraint
3317+
after <command>ATTACH PARTITION</>isfinished.
33183318
</para>
33193319
</sect3>
33203320

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -781,23 +781,24 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
781781
<literal>FOREIGN KEY</literal> constraints are not considered.
782782
If any of the <literal>CHECK</literal> constraints of the table being
783783
attached is marked <literal>NO INHERIT</literal>, the command will fail;
784-
sucha constraintmust be recreated without the <literal>NO INHERIT</literal>
785-
clause.
784+
suchconstraintsmust be recreated without the
785+
<literal>NO INHERIT</literal>clause.
786786
</para>
787787

788788
<para>
789789
If the new partition is a regular table, a full table scan is performed
790-
to check that no existing row in the table violates the partition
791-
constraint. It is possible to avoid this scan by adding a valid
792-
<literal>CHECK</literal> constraint to the table that would allow only
793-
the rows satisfying the desired partition constraint before running this
794-
command. It will be determined using such a constraint that the table
795-
need not be scanned to validate the partition constraint. This does not
796-
work, however, if any of the partition keys is an expression and the
797-
partition does not accept <literal>NULL</literal> values. If attaching
798-
a list partition that will not accept <literal>NULL</literal> values,
799-
also add <literal>NOT NULL</literal> constraint to the partition key
800-
column, unless it's an expression.
790+
to check that existing rows in the table do not violate the partition
791+
constraint. It is possible to avoid this scan by adding a valid
792+
<literal>CHECK</literal> constraint to the table that allows only
793+
rows satisfying the desired partition constraint before running this
794+
command. The <literal>CHECK</literal> constraint will be used to
795+
determine that the table need not be scanned to validate the partition
796+
constraint. This does not work, however, if any of the partition keys
797+
is an expression and the partition does not accept
798+
<literal>NULL</literal> values. If attaching a list partition that will
799+
not accept <literal>NULL</literal> values, also add
800+
<literal>NOT NULL</literal> constraint to the partition key column,
801+
unless it's an expression.
801802
</para>
802803

803804
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp