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

Commit5c5b911

Browse files
committed
Using canonicalize_qual() to get rid of duplicate index predicate
conditions is overkill; set_union() does the job about as well, andmuch more efficiently. Furthermore this avoids assuming thatcanonicalize_qual() will check for duplicate clauses at all, whichit may not always do.
1 parentb53ca9b commit5c5b911

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.151 2003/12/28 21:57:37 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.152 2003/12/29 22:22:45 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -3901,23 +3901,22 @@ genericcostestimate(Query *root, RelOptInfo *rel,
39013901
/*
39023902
* If the index is partial, AND the index predicate with the
39033903
* explicitly given indexquals to produce a more accurate idea of the
3904-
* index restriction. This may produce redundant clauses, which we
3905-
* hope that canonicalize_qual and clauselist_selectivity will deal with
3906-
* intelligently.
3904+
* index selectivity. This may produce redundant clauses. We can get
3905+
* rid of exact duplicates by using set_union(). We expect that most
3906+
* cases of partial redundancy (such as "x < 4" from the qual and
3907+
* "x < 5" from the predicate) will be recognized and handled correctly
3908+
* by clauselist_selectivity(). This assumption is somewhat fragile,
3909+
* since it depends on pred_test() and clauselist_selectivity() having
3910+
* similar capabilities, and there are certainly many cases where we will
3911+
* end up with a too-low selectivity estimate. This will bias the system
3912+
* in favor of using partial indexes where possible, which is not
3913+
* necessarily a bad thing. But it'd be nice to do better someday.
39073914
*
3908-
* Note that index->indpred and indexQuals are both in implicit-AND form
3909-
* to start with, which we have to make explicit to hand to
3910-
* canonicalize_qual, and then we convert back to implicit-AND form.
3915+
* Note that index->indpred and indexQuals are both in implicit-AND form,
3916+
* so ANDing them together just takes merging the lists.
39113917
*/
39123918
if (index->indpred!=NIL)
3913-
{
3914-
Expr*andedQuals;
3915-
3916-
andedQuals=make_ands_explicit(nconc(listCopy(index->indpred),
3917-
indexQuals));
3918-
andedQuals=canonicalize_qual(andedQuals);
3919-
selectivityQuals=make_ands_implicit(andedQuals);
3920-
}
3919+
selectivityQuals=set_union(index->indpred,indexQuals);
39213920

39223921
/* Estimate the fraction of main-table tuples that will be visited */
39233922
*indexSelectivity=clauselist_selectivity(root,selectivityQuals,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp