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

Commiteed57b1

Browse files
committed
Fix choose_bitmap_and() so that partial index predicates are considered when
deciding whether a potential additional indexscan is redundant or not. As nowcoded, any use of a partial index that was already used in a previous AND armwill be rejected as redundant. This might be overly restrictive, but notconsidering the point at all is definitely bad, as per example in bug #2441from Arjen van der Meijden. In particular, a clauseless scan of a partialindex was *never* considered redundant by the previous coding, and that'ssurely wrong. Being more flexible would also require some considerationof how not to double-count the index predicate's selectivity.
1 parentf323252 commiteed57b1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

‎src/backend/optimizer/path/indxpath.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.205 2006/05/1817:12:10 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.206 2006/05/1819:56:46 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -616,10 +616,10 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths)
616616
* non-selective. In any case, we'd surely be drastically misestimating
617617
* the selectivity if we count the same condition twice.
618618
*
619-
*XXX is there any risk of throwing away a useful partial index here
620-
*because we don't explicitly look at indpred? At least in simple cases,
621-
* the partial indexwill sort before competing non-partial indexes and so
622-
*it makes the right choice, but perhaps we need to work harder.
619+
*We include index predicate conditions in the redundancy test. Because
620+
*the test is just for pointer equality and not equal(), the effect is
621+
*that use ofthesamepartial indexin two different AND elements is
622+
*considered redundant. (XXX is this too strong?)
623623
*
624624
* Note: outputting the selected sub-paths in selectivity order is a good
625625
* thing even if we weren't using that as part of the selection method,
@@ -732,14 +732,14 @@ bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel, List *paths)
732732
/*
733733
* pull_indexpath_quals
734734
*
735-
* Given the Path structure for a plain or bitmap indexscan, extract a
736-
*listofRestrictInfo nodes forall the indexquals used in the Path.
735+
* Given the Path structure for a plain or bitmap indexscan, extract a list
736+
* of all the indexquals and index predicate conditions used in the Path.
737737
*
738738
* This is sort of a simplified version of make_restrictinfo_from_bitmapqual;
739739
* here, we are not trying to produce an accurate representation of the AND/OR
740740
* semantics of the Path, but just find out all the base conditions used.
741741
*
742-
* The result list contains pointers to theRestrictInfos used in the Path,
742+
* The result list contains pointers to theexpressions used in the Path,
743743
* but all the list cells are freshly built, so it's safe to destructively
744744
* modify the list (eg, by concat'ing it with other lists).
745745
*/
@@ -777,7 +777,8 @@ pull_indexpath_quals(Path *bitmapqual)
777777
{
778778
IndexPath*ipath= (IndexPath*)bitmapqual;
779779

780-
result=list_copy(ipath->indexclauses);
780+
result=get_actual_clauses(ipath->indexclauses);
781+
result=list_concat(result,list_copy(ipath->indexinfo->indpred));
781782
}
782783
else
783784
elog(ERROR,"unrecognized node type: %d",nodeTag(bitmapqual));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp