@@ -2979,15 +2979,16 @@ VALUES ('Albany', NULL, NULL, 'NY');
2979
2979
<para>
2980
2980
Individual partitions are linked to the partitioned table with inheritance
2981
2981
behind-the-scenes; however, it is not possible to use some of the
2982
- inheritance features discussed in the previous section with partitioned
2983
- tables and partitions. For example, a partition cannot have any parents
2984
- other than the partitioned table it is a partition of, nor can a regular
2985
- table inherit from a partitioned table making the latter its parent.
2986
- That means partitioned tables and partitions do not participate in
2987
- inheritance with regular tables. Since a partition hierarchy consisting
2988
- of the partitioned table and its partitions is still an inheritance
2989
- hierarchy, all the normal rules of inheritance apply as described in
2990
- <xref linkend="ddl-inherit"/> with some exceptions, most notably:
2982
+ generic features of inheritance (discussed below) with declaratively
2983
+ partitioned tables or their partitions. For example, a partition
2984
+ cannot have any parents other than the partitioned table it is a
2985
+ partition of, nor can a regular table inherit from a partitioned table
2986
+ making the latter its parent. That means partitioned tables and their
2987
+ partitions do not participate in inheritance with regular tables.
2988
+ Since a partition hierarchy consisting of the partitioned table and its
2989
+ partitions is still an inheritance hierarchy, all the normal rules of
2990
+ inheritance apply as described in <xref linkend="ddl-inherit"/> with
2991
+ some exceptions, most notably:
2991
2992
2992
2993
<itemizedlist>
2993
2994
<listitem>
@@ -3003,23 +3004,28 @@ VALUES ('Albany', NULL, NULL, 'NY');
3003
3004
<listitem>
3004
3005
<para>
3005
3006
Using <literal>ONLY</literal> to add or drop a constraint on only the
3006
- partitioned table is supported when there are no partitions. Once
3007
+ partitioned table is supported as long as there are no partitions. Once
3007
3008
partitions exist, using <literal>ONLY</literal> will result in an error
3008
3009
as adding or dropping constraints on only the partitioned table, when
3009
- partitions exist, is not supported. Instead, constraints can be added
3010
- or dropped, when they are not present in the parent table, directly on
3011
- the partitions. As a partitioned table does not have any data
3012
- directly, attempts to use <command>TRUNCATE</command>
3013
- <literal>ONLY</literal> on a partitioned table will always return an
3014
- error.
3010
+ partitions exist, is not supported. Instead, constraints on the
3011
+ partitions themselves can be added and (if they are not present in the
3012
+ parent table) dropped.
3013
+ </para>
3014
+ </listitem>
3015
+
3016
+ <listitem>
3017
+ <para>
3018
+ As a partitioned table does not have any data directly, attempts to use
3019
+ <command>TRUNCATE</command> <literal>ONLY</literal> on a partitioned
3020
+ table will always return an error.
3015
3021
</para>
3016
3022
</listitem>
3017
3023
3018
3024
<listitem>
3019
3025
<para>
3020
3026
Partitions cannot have columns that are not present in the parent. It
3021
- is neither possible to specify columns when creating partitions with
3022
- <command>CREATE TABLE</command> nor is it possible to add columns to
3027
+ is not possible to specify columns when creating partitions with
3028
+ <command>CREATE TABLE</command>, nor is it possible to add columns to
3023
3029
partitions after-the-fact using <command>ALTER TABLE</command>. Tables may be
3024
3030
added as a partition with <command>ALTER TABLE ... ATTACH PARTITION</command>
3025
3031
only if their columns exactly match the parent, including any
@@ -3044,7 +3050,7 @@ VALUES ('Albany', NULL, NULL, 'NY');
3044
3050
3045
3051
<para>
3046
3052
Updating the partition key of a row might cause it to be moved into a
3047
- different partition where this row satisfies its partition constraint .
3053
+ different partition where this row satisfies the partition bounds .
3048
3054
</para>
3049
3055
3050
3056
<sect3 id="ddl-partitioning-declarative-example">
@@ -3358,15 +3364,15 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02
3358
3364
While the built-in declarative partitioning is suitable for most
3359
3365
common use cases, there are some circumstances where a more flexible
3360
3366
approach may be useful. Partitioning can be implemented using table
3361
- inheritance, which allows for several features which are not supported
3367
+ inheritance, which allows for several features not supported
3362
3368
by declarative partitioning, such as:
3363
3369
3364
3370
<itemizedlist>
3365
3371
<listitem>
3366
3372
<para>
3367
- Partitioning enforces a rule that all partitions must have exactly
3368
- the same set of columns as the parent, but table inheritance allows
3369
- children to have extra columns not present in the parent.
3373
+ For declarative partitioning, partitions must have exactly the same set
3374
+ of columns as the partitioned table, whereas with table inheritance,
3375
+ child tables may have extra columns not present in the parent.
3370
3376
</para>
3371
3377
</listitem>
3372
3378
@@ -3768,7 +3774,8 @@ ANALYZE measurement;
3768
3774
3769
3775
<para>
3770
3776
<firstterm>Partition pruning</firstterm> is a query optimization technique
3771
- that improves performance for partitioned tables. As an example:
3777
+ that improves performance for declaratively partitioned tables.
3778
+ As an example:
3772
3779
3773
3780
<programlisting>
3774
3781
SET enable_partition_pruning = on; -- the default
@@ -3786,12 +3793,11 @@ SELECT count(*) FROM measurement WHERE logdate >= DATE '2008-01-01';
3786
3793
</para>
3787
3794
3788
3795
<para>
3789
- You can use the <command>EXPLAIN</command> command to show the
3790
- difference between a plan whose partitions have been pruned from one
3791
- whose partitions haven't, by using the
3792
- <xref linkend="guc-enable-partition-pruning"/> configuration
3793
- parameter. A typical unoptimized plan for this type of table setup
3794
- is:
3796
+ By using the EXPLAIN command and the <xref
3797
+ linkend="guc-enable-partition-pruning"/> configuration parameter, it's
3798
+ possible to show the difference between a plan for which partitions have
3799
+ been pruned and one for which they have not. A typical unoptimized
3800
+ plan for this type of table setup is:
3795
3801
<programlisting>
3796
3802
SET enable_partition_pruning = off;
3797
3803
EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2008-01-01';
@@ -3892,9 +3898,9 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2008-01-01';
3892
3898
Currently, pruning of partitions during the planning of an
3893
3899
<command>UPDATE</command> or <command>DELETE</command> command is
3894
3900
implemented using the constraint exclusion method (however, it is
3895
- still ruled by the <literal>enable_partition_pruning</literal>
3896
- setting instead of <literal>constraint_exclusion</literal>) —
3897
- see the next section for details and caveats that apply.
3901
+ controlled by the <literal>enable_partition_pruning</literal> rather than
3902
+ <literal>constraint_exclusion</literal>) — see the following section
3903
+ for details and caveats that apply.
3898
3904
</para>
3899
3905
3900
3906
<para>
@@ -3927,10 +3933,10 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2008-01-01';
3927
3933
Constraint exclusion works in a very similar way to partition
3928
3934
pruning, except that it uses each table's <literal>CHECK</literal>
3929
3935
constraints — which gives it its name — whereas partition
3930
- pruning uses the table's partitioning constraint , which exists only in
3931
- the case of declarative partitioning. Another difference is that it
3932
- is only applied at plan time; there is no attempt to remove
3933
- partitions at execution time.
3936
+ pruning uses the table's partition bounds , which exists only in the
3937
+ case of declarative partitioning. Another difference is that
3938
+ constraint exclusion is only applied at plan time; there is no attempt
3939
+ to remove partitions at execution time.
3934
3940
</para>
3935
3941
3936
3942
<para>
@@ -3959,8 +3965,8 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2008-01-01';
3959
3965
<itemizedlist>
3960
3966
<listitem>
3961
3967
<para>
3962
- Constraint exclusion is only applied during query planning; it is
3963
- not applied at execution time like partition pruning does .
3968
+ Constraint exclusion is only applied during query planning; unlike
3969
+ partition pruning, it cannot be applied during query execution .
3964
3970
</para>
3965
3971
</listitem>
3966
3972
@@ -3970,7 +3976,7 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2008-01-01';
3970
3976
clause contains constants (or externally supplied parameters).
3971
3977
For example, a comparison against a non-immutable function such as
3972
3978
<function>CURRENT_TIMESTAMP</function> cannot be optimized, since the
3973
- planner cannot know which partition the function value might fall
3979
+ planner cannot know which partition the function's value might fall
3974
3980
into at run time.
3975
3981
</para>
3976
3982
</listitem>
0 commit comments