forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2e824a8
committed
Rewrite choose_bitmap_and() to make it more robust in the presence of
competing alternatives for indexes to use in a bitmap scan. The formercoding took estimated selectivity as an overriding factor, causing it tosometimes choose indexes that were much slower to scan than ones with aslightly worse selectivity. It was also too narrow-minded about whichcombinations of indexes to consider ANDing. The rewrite makes it pay moreattention to index scan cost than selectivity; this seems sane since it'simpossible to have very bad selectivity with low cost, whereas the reverseisn't true. Also, we now consider each index alone, as well as addingeach index to an AND-group led by each prior index, for a total of aboutO(N^2) rather than O(N) combinations considered. This makes the resultsmuch less dependent on the exact order in which the indexes areconsidered. It's still a lot cheaper than an O(2^N) exhaustive search.A prefilter step eliminates all but the cheapest of those indexes usingthe same set of WHERE conditions, to keep the effective value of N down inscenarios where the DBA has created lots of partially-redundant indexes.1 parent2b99411 commit2e824a8
1 file changed
+279
-150
lines changed0 commit comments
Comments
(0)