yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.86k stars 1.05k forks source link

[YSQL] Use local index filters for Bitmap Scans #21634

Open timothy-e opened 5 months ago

timothy-e commented 5 months ago

Jira Link: DB-10529

Description

Bitmap Index Scans support remote index filters. We could also support non-pushable filters on the index columns by retrieving the index columns to the postgres layer too.

This could look something like:

/*+ BitmapScan(multi) */ EXPLAIN (ANALYZE, DIST)
SELECT * FROM multi WHERE c BETWEEN 10 AND 15 AND a < 30 AND c < date_part('year', NOW()) ORDER BY a;
                                                QUERY PLAN
-----------------------------------------------------------------------------------------------------------
 Sort  (cost=7.87..7.89 rows=10 width=16) (actual rows=2 loops=1)
   Sort Key: a
   Sort Method: quicksort
   ->  YB Bitmap Table Scan on multi  (cost=3.53..7.70 rows=10 width=16) (actual rows=2 loops=1)
         Storage Table Read Requests: 1
         Storage Table Rows Scanned: 2
         ->  Bitmap Index Scan on multi_c_a_idx  (cost=0.00..3.53 rows=10 width=0) (actual rows=2 loops=1)
               Index Cond: ((c >= 10) AND (c <= 15))
               Storage Index Filter: (a < 30)
               Index Filter: (c < date_part('year', NOW()))
               Storage Index Read Requests: 1
               Storage Index Rows Scanned: 2
 Storage Read Requests: 2
 Storage Rows Scanned: 4
 Storage Write Requests: 0
 Storage Flush Requests: 0
(15 rows)

It could reduce the number of ybctids we have to store in the set, and the number of rows we request from the main table.

Issue Type

kind/enhancement

Warning: Please confirm that this issue does not contain any sensitive information

timothy-e commented 5 months ago

Created #21982 to track the more general case of enabling for all indexes.