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

Commit2467934

Browse files
committed
Modify partial-index-predicate applicability tester to test whether
clauses are equal(), before trying to match them up using btree opclassinference rules. This allows it to recognize many simple cases involvingnon-btree operations, for example 'x IS NULL'. Clean up code a little.
1 parent7d6fbe1 commit2467934

File tree

3 files changed

+98
-82
lines changed

3 files changed

+98
-82
lines changed

‎doc/src/sgml/ref/create_index.sgml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v 1.20 2001/07/16 05:06:57 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v 1.21 2001/08/06 18:09:45 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -256,21 +256,26 @@ ERROR: Cannot create index: 'index_name' already exists.
256256
billed and unbilled orders where the unbilled orders take up a small
257257
fraction of the total table and yet that is an often used section, you
258258
can improve performance by creating an index on just that portion.
259+
Another possible application is to use <command>WHERE</command> with
260+
<command>UNIQUE</command> to enforce uniqueness over a subset of a
261+
table.
259262
</para>
260263

261264
<para>
262265
The expression used in the <command>WHERE</command> clause may refer
263266
only to columns of the underlying table (but it can use all columns,
264-
not only the one(s) being indexed). Currently, the
265-
<productname>PostgreSQL</productname> planner can only devise query
266-
plans that make use of a partial index when the predicate is built from
267-
<command>AND</command> and <command>OR</command> combinations of
268-
elements of the form
269-
<firstterm>column</firstterm>
270-
<firstterm>operator</firstterm>
271-
<firstterm>constant</firstterm>.
272-
However, more general predicates may still be useful in conjunction
273-
with UNIQUE indexes, to enforce uniqueness over a subset of a table.
267+
not only the one(s) being indexed). Presently, sub-SELECTs and
268+
aggregate expressions are also forbidden in <command>WHERE</command>.
269+
</para>
270+
271+
<para>
272+
All functions and operators used in an index definition must be
273+
<firstterm>cachable</>, that is, their results must depend only on
274+
their input arguments and never on any outside influence (such as
275+
the contents of another table or the current time). This restriction
276+
ensures that the behavior of the index is well-defined. To use a
277+
user-defined function in an index, remember to mark the function cachable
278+
when you create it.
274279
</para>
275280

276281
<para>

‎src/backend/commands/indexcmds.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.53 2001/07/17 21:53:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.54 2001/08/06 18:09:45 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -146,10 +146,12 @@ DefineIndex(char *heapRelationName,
146146
/*
147147
* Convert the partial-index predicate from parsetree form to
148148
* an implicit-AND qual expression, for easier evaluation at runtime.
149+
* While we are at it, we reduce it to a canonical (CNF or DNF) form
150+
* to simplify the task of proving implications.
149151
*/
150152
if (predicate!=NULL&&rangetable!=NIL)
151153
{
152-
cnfPred=cnfify((Expr*)copyObject(predicate), true);
154+
cnfPred=canonicalize_qual((Expr*)copyObject(predicate), true);
153155
fix_opids((Node*)cnfPred);
154156
CheckPredicate(cnfPred,rangetable,relationId);
155157
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp