Hi,

choose_bitmap_and() rejects a partial index whose predicate is implied
by the quals already chosen, to avoid double-counting selectivity, but
it doesn't check the reverse: when a clauseless partial index leads the
AND group and a later index's quals imply its predicate.  The BitmapAnd
then can't remove any rows, yet it's estimated as far more selective
(about 15 rows vs 2,000 actual in the attached repro), and with
random_page_cost = 1.1 it gets chosen, including on the outer side of a
nested-loop semi join. With the default random_page_cost the plan is
unchanged.

The attached patch adds the mirror-image check, requiring that the
predicate be fully implied and that both paths be plain IndexPaths, and
includes regression tests. A repro script is attached as well.

Thoughts?

- Krishna

Attachment: repro.sql
Description: Binary data

Attachment: v1-0001-Avoid-redundant-BitmapAnd-with-a-clauseless-partial-.patch
Description: Binary data

Reply via email to