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

Commit4c2d3cc

Browse files
committed
Add a caveat pointing out that constraint exclusion doesn't work with
constraints the planner is unable to disprove, hence simple btree-compatibleconditions should be used. We've seen people try to get cute with stufflike date_part(something) = something at least twice now. Even if wewanted to try to teach predtest.c about the properties of date_part,most of the useful variants aren't immutable so nothing could be proved.
1 parent8f3d077 commit4c2d3cc

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

‎doc/src/sgml/ddl.sgml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.75 2007/05/15 19:43:50 neilc Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.76 2007/06/20 23:11:38 tgl Exp $ -->
22

33
<chapter id="ddl">
44
<title>Data Definition</title>
@@ -2778,7 +2778,7 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate &gt;= DATE '2006-01-01';
27782778
<para>
27792779
Constraint exclusion only works when the query's <literal>WHERE</>
27802780
clause contains constants. A parameterized query will not be
2781-
optimized, since the planner cannot knowwhat partitions the
2781+
optimized, since the planner cannot knowwhich partitions the
27822782
parameter value might select at run time. For the same reason,
27832783
<quote>stable</> functions such as <function>CURRENT_DATE</function>
27842784
must be avoided.
@@ -2787,9 +2787,21 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate &gt;= DATE '2006-01-01';
27872787

27882788
<listitem>
27892789
<para>
2790-
All constraints on all partitions of the master table are considered for
2791-
constraint exclusion, so large numbers of partitions are likely to
2792-
increase query planning time considerably.
2790+
Keep the partitioning constraints simple, else the planner may not be
2791+
able to prove that partitions don't need to be visited. Use simple
2792+
equality conditions for list partitioning, or simple
2793+
range tests for range partitioning, as illustrated in the preceding
2794+
examples. A good rule of thumb is that partitioning constraints should
2795+
contain only comparisons of the partitioning column(s) to constants
2796+
using btree-indexable operators.
2797+
</para>
2798+
</listitem>
2799+
2800+
<listitem>
2801+
<para>
2802+
All constraints on all partitions of the master table are examined
2803+
during constraint exclusion, so large numbers of partitions are likely
2804+
to increase query planning time considerably.
27932805
</para>
27942806
</listitem>
27952807

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp