| -- |
| -- Test union bitmap batch words for multivalues index scan like where x in (x1, x2) or x > v |
| -- which creates BitmapAnd plan on two bitmap indexs that match multiple keys by using in in where clause |
| -- |
| CREATE TABLE bmunion (a int, b int); |
| CREATE |
| INSERT INTO bmunion SELECT (r%53), (r%59) FROM generate_series(1,70000) r; |
| INSERT 70000 |
| CREATE INDEX i_bmtest2_a ON bmunion USING BITMAP(a); |
| CREATE |
| CREATE INDEX i_bmtest2_b ON bmunion USING BITMAP(b); |
| CREATE |
| INSERT INTO bmunion SELECT 53, 1 FROM generate_series(1, 1000); |
| INSERT 1000 |
| |
| SET optimizer_enable_tablescan=OFF; |
| SET |
| SET optimizer_enable_dynamictablescan=OFF; |
| SET |
| -- Inject fault for planner so that it could produce bitMapAnd plan node. |
| SELECT gp_inject_fault('simulate_bitmap_and', 'skip', dbid) FROM gp_segment_configuration WHERE role = 'p' AND content = -1; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| EXPLAIN (COSTS OFF) SELECT count(*) FROM bmunion WHERE a = 53 AND b < 3; |
| QUERY PLAN |
| ---------------------------------------------------- |
| Aggregate |
| -> Bitmap Heap Scan on bmunion |
| Recheck Cond: ((b < 3) AND (a = 53)) |
| -> BitmapAnd |
| -> Bitmap Index Scan on i_bmtest2_b |
| Index Cond: (b < 3) |
| -> Bitmap Index Scan on i_bmtest2_a |
| Index Cond: (a = 53) |
| Optimizer: Postgres query optimizer |
| (9 rows) |
| SELECT gp_inject_fault('simulate_bitmap_and', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' AND content = -1; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| SELECT gp_inject_fault('simulate_bitmap_and', 'skip', dbid) FROM gp_segment_configuration WHERE role = 'p' AND content = -1; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| SELECT count(*) FROM bmunion WHERE a = 53 AND b < 3; |
| count |
| ------- |
| 1000 |
| (1 row) |
| SELECT gp_inject_fault('simulate_bitmap_and', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' AND content = -1; |
| gp_inject_fault |
| ----------------- |
| Success: |
| (1 row) |
| |
| RESET optimizer_enable_tablescan; |
| RESET |
| RESET optimizer_enable_dynamictablescan; |
| RESET |
| |
| DROP TABLE bmunion; |
| DROP |