Closed shantanugupta-yb closed 1 week ago
Each of the bitmap scan examples in PG are a bitmap scan with a single bitmap index scan.
This pattern occurs because of a difference in the storage layer between YB and PG, mentioned in the bitmap scan blog post:
If fewer tuples are required, fewer pages will be fetched, and so access costs are similar to random access costs. As the number of pages fetched increases, access costs approach sequential costs.
This explains an interesting pattern on Postgres, where a query with only one condition might use a Bitmap Index Scan because the almost sequential access patterns of bitmap scans are beneficial. If the query selects fewer rows, it’s more likely to choose an Index Scan. If it selects more rows, it’s more likely to choose a Sequential Scan. Somewhere in between, it will use a bitmap scan. This is due to Postgres’s disk access cost modeling.
YB still has random access from the main table, regardless of how many rows are selected, so this benefit never kicks in. On YB, a Bitmap Scan with a single BItmap Index Scan is always strictly worse than an Index Scan (because of the overhead of constructing bitmaps).
Jira Link: DB-13302
Description
List of microbenchmarks for which PG has picked bitmap scan but YB did not.
Query and Plan details can be found here
YB build: 2.23.1.0-b174 (12Sept build)
List of gflags used in above test:
Issue Type
kind/bug
Warning: Please confirm that this issue does not contain any sensitive information