| From: | Krishna Sarabu <krishna(dot)sarabu(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Avoid redundant BitmapAnd with a clauseless partial index |
| Date: | 2026-11-10 05:28:18 |
| Message-ID: | CALdaZOikwmOS8_dSMm85xR1MZXPuHVfODJG7n1zS3nd2w+4VMw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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 | Content-Type | Size |
|---|---|---|
| repro.sql | application/octet-stream | 2.4 KB |
| v1-0001-Avoid-redundant-BitmapAnd-with-a-clauseless-partial-.patch | application/octet-stream | 12.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | João Rito | 2026-11-10 05:33:37 | Re: Standby stuck after walreceiver restart just before a WAL segment boundary |
| Previous Message | João Rito | 2026-11-10 05:14:37 | Re: [PATCH] Fix timeline history after recovery stops on an ancestor |