From 58771875a40e892c99d7663aadf4ab33ce797b27 Mon Sep 17 00:00:00 2001 From: Timothy Elgersma Date: Fri, 3 May 2024 13:59:52 +0000 Subject: [PATCH] [#22203] YSQL: Add new flag yb_enable_bitmapscan = false Summary: `enable_bitmapscan` does not disable bitmap scan in all cases - e.g. if sequential scan and bitmap scan are both disabled, they both have `disable_cost` added to their plan costs. Then bitmap scan might still be the lowest costed plan. Add a new flag `yb_enable_bitmapscan` that prevents YB Bitmap Scan plans from being created for YB relations. The default of this new flag is false, to prevent YB Bitmap Scans from being chosen until bitmap scans are more stable. The default of `enable_bitmapscan` is reset to true, to allow bitmap scans on PG temp tables by default again. This restores the default behaviour for temp tables. | | enable_bitmapscan = false | enable_bitmapscan = true | yb_enable_bitmapscan = false | PG bitmap scans have `disable_cost` added, YB bitmap scans disabled | PG bitmap scans enabled, YB bitmap scans disabled | yb_enable_bitmapscan = true | YB + PG bitmap scans have `disable_cost` added | YB + PG bitmap scans are enabled and costed normally Jira: DB-11125 Test Plan: ``` ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressYbBitmapScans' ``` Reviewers: amartsinchyk, tnayak, mtakahara Reviewed By: mtakahara Subscribers: smishra, yql Differential Revision: https://phorge.dev.yugabyte.com/D34646 --- .../src/backend/optimizer/path/costsize.c | 6 +- .../src/backend/optimizer/path/indxpath.c | 49 ++++--- src/postgres/src/backend/utils/misc/guc.c | 12 +- src/postgres/src/include/optimizer/cost.h | 1 + .../regress/expected/yb_bitmap_scan_joins.out | 1 + .../test/regress/expected/yb_bitmap_scans.out | 132 ++++++++++++++++++ .../expected/yb_bitmap_scans_distinct.out | 1 + .../src/test/regress/expected/yb_guc.out | 2 + .../regress/expected/yb_partition_prune.out | 2 + .../test/regress/expected/yb_pg_select.out | 5 +- .../test/regress/sql/yb_bitmap_scan_joins.sql | 1 + .../src/test/regress/sql/yb_bitmap_scans.sql | 47 ++++++- .../regress/sql/yb_bitmap_scans_distinct.sql | 1 + src/postgres/src/test/regress/sql/yb_guc.sql | 2 + .../test/regress/sql/yb_partition_prune.sql | 3 + .../src/test/regress/sql/yb_pg_select.sql | 5 +- .../pg_hint_plan/expected/yb_pg_init.out | 2 +- .../expected/yb_pg_pg_hint_plan.out | 1 + .../pg_hint_plan/sql/yb_pg_pg_hint_plan.sql | 1 + 19 files changed, 248 insertions(+), 26 deletions(-) diff --git a/src/postgres/src/backend/optimizer/path/costsize.c b/src/postgres/src/backend/optimizer/path/costsize.c index bfd750a42d0e..b487cd003b55 100644 --- a/src/postgres/src/backend/optimizer/path/costsize.c +++ b/src/postgres/src/backend/optimizer/path/costsize.c @@ -178,7 +178,8 @@ int max_parallel_workers_per_gather = 2; bool enable_seqscan = true; bool enable_indexscan = true; bool enable_indexonlyscan = true; -bool enable_bitmapscan = false; +bool enable_bitmapscan = true; +bool yb_enable_bitmapscan = false; bool enable_tidscan = true; bool enable_sort = true; bool enable_hashagg = true; @@ -1126,6 +1127,7 @@ cost_yb_bitmap_table_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, Path *bitmapqual, double loop_count) { Assert(baserel->is_yb_relation); + Assert(yb_enable_bitmapscan); return cost_bitmap_heap_scan(path, root, baserel, param_info, bitmapqual, loop_count); } @@ -6341,7 +6343,7 @@ yb_get_index_tuple_width(IndexOptInfo *index, Oid baserel_oid, /* Aggregate the width of the columns in the secondary index */ for (int i = 0; i < index->ncolumns; i++) { - index_tuple_width += + index_tuple_width += index->rel->attr_widths[index->indexkeys[i] - index->rel->min_attr]; } index_tuple_width += HIDDEN_COLUMNS_SIZE; diff --git a/src/postgres/src/backend/optimizer/path/indxpath.c b/src/postgres/src/backend/optimizer/path/indxpath.c index d4db47270b34..5dd026e0ec06 100644 --- a/src/postgres/src/backend/optimizer/path/indxpath.c +++ b/src/postgres/src/backend/optimizer/path/indxpath.c @@ -349,12 +349,16 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel) if (IsYugaByteEnabled() && rel->is_yb_relation) { - YbBitmapTablePath *bpath; - bpath = create_yb_bitmap_table_path(root, rel, bitmapqual, - rel->lateral_relids, 1.0, 0); - add_path(rel, (Path *) bpath); + if (yb_enable_bitmapscan) + { + YbBitmapTablePath *bpath; + bpath = create_yb_bitmap_table_path(root, rel, bitmapqual, + rel->lateral_relids, 1.0, + 0); + add_path(rel, (Path *) bpath); - /* TODO(#20575): support parallel bitmap scans */ + /* TODO(#20575): support parallel bitmap scans */ + } } else { @@ -430,16 +434,23 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel) loop_count = get_loop_count(root, rel->relid, required_outer); if (IsYugaByteEnabled() && rel->is_yb_relation) - bpath = (Path *) create_yb_bitmap_table_path(root, rel, - bitmapqual, - required_outer, - loop_count, 0); - + { + if (yb_enable_bitmapscan) + { + bpath = (Path *) create_yb_bitmap_table_path(root, rel, + bitmapqual, + required_outer, + loop_count, 0); + add_path(rel, bpath); + } + } else + { bpath = (Path *) create_bitmap_heap_path(root, rel, bitmapqual, required_outer, loop_count, 0); - add_path(rel, bpath); + add_path(rel, bpath); + } } } } @@ -1703,6 +1714,9 @@ generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, List *all_clauses; ListCell *lc; + if (IsYugaByteEnabled() && rel->is_yb_relation && !yb_enable_bitmapscan) + return NIL; + /* * We can use both the current and other clauses as context for * build_paths_for_OR; no need to remove ORs from the lists. @@ -2110,12 +2124,13 @@ yb_bitmap_scan_cost_est(PlannerInfo *root, RelOptInfo *rel, Path *ipath) */ bpath.path.parallel_workers = 0; - /* Now we can do cost_yb_bitmap_table_scan */ - cost_yb_bitmap_table_scan(&bpath.path, root, rel, - bpath.path.param_info, - ipath, - get_loop_count(root, rel->relid, - PATH_REQ_OUTER(ipath))); + if (yb_enable_bitmapscan) + /* Now we can do cost_yb_bitmap_table_scan */ + cost_yb_bitmap_table_scan(&bpath.path, root, rel, + bpath.path.param_info, + ipath, + get_loop_count(root, rel->relid, + PATH_REQ_OUTER(ipath))); return bpath.path.total_cost; } diff --git a/src/postgres/src/backend/utils/misc/guc.c b/src/postgres/src/backend/utils/misc/guc.c index 62cc8bf3a561..0a90cbbad491 100644 --- a/src/postgres/src/backend/utils/misc/guc.c +++ b/src/postgres/src/backend/utils/misc/guc.c @@ -921,7 +921,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &enable_bitmapscan, - false, + true, NULL, NULL, NULL }, { @@ -1112,6 +1112,16 @@ static struct config_bool ConfigureNamesBool[] = false, NULL, NULL, NULL }, + { + {"yb_enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD, + gettext_noop("Enables the planner's use of YB bitmap-scan plans."), + gettext_noop("To use YB Bitmap Scans, both yb_enable_bitmapscan " + "and enable_bitmapscan must be true.") + }, + &yb_enable_bitmapscan, + false, + NULL, NULL, NULL + }, { {"enable_partition_pruning", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enable plan-time and run-time partition pruning."), diff --git a/src/postgres/src/include/optimizer/cost.h b/src/postgres/src/include/optimizer/cost.h index 7b799f937bb4..2dc3f04fbe3f 100644 --- a/src/postgres/src/include/optimizer/cost.h +++ b/src/postgres/src/include/optimizer/cost.h @@ -120,6 +120,7 @@ extern PGDLLIMPORT bool enable_seqscan; extern PGDLLIMPORT bool enable_indexscan; extern PGDLLIMPORT bool enable_indexonlyscan; extern PGDLLIMPORT bool enable_bitmapscan; +extern PGDLLIMPORT bool yb_enable_bitmapscan; extern PGDLLIMPORT bool enable_tidscan; extern PGDLLIMPORT bool enable_sort; extern PGDLLIMPORT bool enable_hashagg; diff --git a/src/postgres/src/test/regress/expected/yb_bitmap_scan_joins.out b/src/postgres/src/test/regress/expected/yb_bitmap_scan_joins.out index e2b893e75616..de73d50501a9 100644 --- a/src/postgres/src/test/regress/expected/yb_bitmap_scan_joins.out +++ b/src/postgres/src/test/regress/expected/yb_bitmap_scan_joins.out @@ -3,6 +3,7 @@ -- SET yb_explain_hide_non_deterministic_fields = true; SET enable_bitmapscan = true; +SET yb_enable_bitmapscan = true; SET yb_prefer_bnl = false; CREATE TABLE joina (k INT, a INT, b INT, PRIMARY KEY (k ASC)); CREATE INDEX ON joina (a ASC); diff --git a/src/postgres/src/test/regress/expected/yb_bitmap_scans.out b/src/postgres/src/test/regress/expected/yb_bitmap_scans.out index dd555864c7f5..daefcf0b884a 100644 --- a/src/postgres/src/test/regress/expected/yb_bitmap_scans.out +++ b/src/postgres/src/test/regress/expected/yb_bitmap_scans.out @@ -2,6 +2,137 @@ -- YB Bitmap Scans (bitmap index scans + YB bitmap table scans) -- SET yb_explain_hide_non_deterministic_fields = true; +-- +-- -- test disabling bitmap scans -- +-- for each combination of yb_enable_bitmapscan and enable_bitmapscan, try +-- 1. a case where the planner chooses bitmap scans +-- 2. a case where we tell the planner to use bitmap scans +-- 3. a case where the alternative option (seq scan) is disabled +-- +CREATE TABLE test_disable(a int, b int); +CREATE INDEX ON test_disable(a ASC); +CREATE INDEX ON test_disable(b ASC); +SET yb_enable_bitmapscan = true; +SET enable_bitmapscan = true; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +----------------------------------------------------- + YB Bitmap Table Scan on test_disable + -> BitmapOr + -> Bitmap Index Scan on test_disable_a_idx + Index Cond: (a < 5) + -> Bitmap Index Scan on test_disable_b_idx + Index Cond: (b < 5) +(6 rows) + +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +----------------------------------------------------- + YB Bitmap Table Scan on test_disable + -> BitmapOr + -> Bitmap Index Scan on test_disable_a_idx + Index Cond: (a < 5) + -> Bitmap Index Scan on test_disable_b_idx + Index Cond: (b < 5) +(6 rows) + +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +----------------------------------------------------- + YB Bitmap Table Scan on test_disable + -> BitmapOr + -> Bitmap Index Scan on test_disable_a_idx + Index Cond: (a < 5) + -> Bitmap Index Scan on test_disable_b_idx + Index Cond: (b < 5) +(6 rows) + +SET yb_enable_bitmapscan = true; +SET enable_bitmapscan = false; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +----------------------------------------------------- + YB Bitmap Table Scan on test_disable + -> BitmapOr + -> Bitmap Index Scan on test_disable_a_idx + Index Cond: (a < 5) + -> Bitmap Index Scan on test_disable_b_idx + Index Cond: (b < 5) +(6 rows) + +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +----------------------------------------------------- + YB Bitmap Table Scan on test_disable + -> BitmapOr + -> Bitmap Index Scan on test_disable_a_idx + Index Cond: (a < 5) + -> Bitmap Index Scan on test_disable_b_idx + Index Cond: (b < 5) +(6 rows) + +SET yb_enable_bitmapscan = false; +SET enable_bitmapscan = true; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +SET yb_enable_bitmapscan = false; +SET enable_bitmapscan = false; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + QUERY PLAN +---------------------------------------- + Seq Scan on test_disable + Storage Filter: ((a < 5) OR (b < 5)) +(2 rows) + +SET yb_enable_bitmapscan = true; SET enable_bitmapscan = true; -- tenk1 already has 4 ASC indexes: unique1, unique2, hundred, and (thousand, tenthous) -- each query has an order by to make asserting results easier @@ -1323,6 +1454,7 @@ CREATE DATABASE colo WITH colocation = true; \c colo; SET yb_explain_hide_non_deterministic_fields = true; SET enable_bitmapscan = true; +SET yb_enable_bitmapscan = true; CREATE TABLE pk_colo (k INT PRIMARY KEY, a INT); CREATE INDEX ON pk_colo(a ASC); INSERT INTO pk_colo SELECT i, i FROM generate_series(1, 1000) i; diff --git a/src/postgres/src/test/regress/expected/yb_bitmap_scans_distinct.out b/src/postgres/src/test/regress/expected/yb_bitmap_scans_distinct.out index f9172df858a2..21757f9583ab 100644 --- a/src/postgres/src/test/regress/expected/yb_bitmap_scans_distinct.out +++ b/src/postgres/src/test/regress/expected/yb_bitmap_scans_distinct.out @@ -2,6 +2,7 @@ -- test distinct bitmap scans (distinct pushdown is not supported by bitmap scans) -- SET yb_explain_hide_non_deterministic_fields = true; +SET yb_enable_bitmapscan = true; CREATE TABLE test_distinct (r1 INT, r2 INT, r3 INT, v INT, PRIMARY KEY(r1 ASC, r2 ASC, r3 ASC)) SPLIT AT VALUES ((1, 1, 500)); INSERT INTO test_distinct (SELECT 1, i%3, i, i/3 FROM GENERATE_SERIES(1, 1000) AS i); -- Add one more distinct value to catch bugs that arise only with more than one distinct value. diff --git a/src/postgres/src/test/regress/expected/yb_guc.out b/src/postgres/src/test/regress/expected/yb_guc.out index 63f5cdcc2476..f937f1635ed4 100644 --- a/src/postgres/src/test/regress/expected/yb_guc.out +++ b/src/postgres/src/test/regress/expected/yb_guc.out @@ -79,6 +79,7 @@ CREATE TABLE test_scan (i int, j int); CREATE INDEX NONCONCURRENTLY ON test_scan (j); -- Don't add (costs off) to EXPLAIN to be able to see when disable_cost=1.0e10 -- is added. +set yb_enable_bitmapscan = on; set enable_seqscan = on; set enable_indexscan = on; set enable_indexonlyscan = on; @@ -352,3 +353,4 @@ ERROR: unrecognized configuration parameter "foo" RESET plpgsql.extra_foo_warnings; WARNING: unrecognized configuration parameter "plpgsql.extra_foo_warnings" DETAIL: "plpgsql" is a reserved prefix. +RESET yb_enable_bitmapscan; diff --git a/src/postgres/src/test/regress/expected/yb_partition_prune.out b/src/postgres/src/test/regress/expected/yb_partition_prune.out index 71f6c589a460..55cec284b45b 100644 --- a/src/postgres/src/test/regress/expected/yb_partition_prune.out +++ b/src/postgres/src/test/regress/expected/yb_partition_prune.out @@ -1,3 +1,4 @@ +set yb_enable_bitmapscan = true; create table ab (a int not null, b int not null) partition by list (a); create table ab_a2 partition of ab for values in(2) partition by list (b); create table ab_a2_b1 partition of ab_a2 for values in (1); @@ -110,4 +111,5 @@ explain (analyze, costs off, summary off, timing off) (31 rows) reset enable_bitmapscan; +reset yb_enable_bitmapscan; drop table ab; diff --git a/src/postgres/src/test/regress/expected/yb_pg_select.out b/src/postgres/src/test/regress/expected/yb_pg_select.out index b628ba8b39fa..2b54e3a94617 100644 --- a/src/postgres/src/test/regress/expected/yb_pg_select.out +++ b/src/postgres/src/test/regress/expected/yb_pg_select.out @@ -1,6 +1,7 @@ -- -- SELECT -- +SET yb_enable_bitmapscan TO on; -- lsm index -- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 -- @@ -292,7 +293,7 @@ SELECT onek2.unique1, onek2.stringu1 FROM onek2 (19 rows) RESET enable_seqscan; -SET enable_bitmapscan = on; +RESET enable_bitmapscan; RESET enable_sort; SELECT two, stringu1, ten, string4 INTO TABLE tmp @@ -694,4 +695,4 @@ LIMIT ALL) ybview ORDER BY unique2; 0 | 998 (2 rows) -RESET enable_bitmapscan; +RESET yb_enable_bitmapscan; diff --git a/src/postgres/src/test/regress/sql/yb_bitmap_scan_joins.sql b/src/postgres/src/test/regress/sql/yb_bitmap_scan_joins.sql index 2338c6ea2924..466887685bd7 100644 --- a/src/postgres/src/test/regress/sql/yb_bitmap_scan_joins.sql +++ b/src/postgres/src/test/regress/sql/yb_bitmap_scan_joins.sql @@ -3,6 +3,7 @@ -- SET yb_explain_hide_non_deterministic_fields = true; SET enable_bitmapscan = true; +SET yb_enable_bitmapscan = true; SET yb_prefer_bnl = false; CREATE TABLE joina (k INT, a INT, b INT, PRIMARY KEY (k ASC)); diff --git a/src/postgres/src/test/regress/sql/yb_bitmap_scans.sql b/src/postgres/src/test/regress/sql/yb_bitmap_scans.sql index a5ca70a2e454..daa896cc182d 100644 --- a/src/postgres/src/test/regress/sql/yb_bitmap_scans.sql +++ b/src/postgres/src/test/regress/sql/yb_bitmap_scans.sql @@ -2,8 +2,52 @@ -- YB Bitmap Scans (bitmap index scans + YB bitmap table scans) -- SET yb_explain_hide_non_deterministic_fields = true; -SET enable_bitmapscan = true; +-- +-- -- test disabling bitmap scans -- +-- for each combination of yb_enable_bitmapscan and enable_bitmapscan, try +-- 1. a case where the planner chooses bitmap scans +-- 2. a case where we tell the planner to use bitmap scans +-- 3. a case where the alternative option (seq scan) is disabled +-- +CREATE TABLE test_disable(a int, b int); +CREATE INDEX ON test_disable(a ASC); +CREATE INDEX ON test_disable(b ASC); + +SET yb_enable_bitmapscan = true; +SET enable_bitmapscan = true; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + +SET yb_enable_bitmapscan = true; +SET enable_bitmapscan = false; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + +SET yb_enable_bitmapscan = false; +SET enable_bitmapscan = true; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + +SET yb_enable_bitmapscan = false; +SET enable_bitmapscan = false; +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ BitmapScan(test_disable) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; +/*+ Set(enable_seqscan false) */ +EXPLAIN (COSTS OFF) SELECT * FROM test_disable WHERE a < 5 OR b < 5; + +SET yb_enable_bitmapscan = true; +SET enable_bitmapscan = true; -- tenk1 already has 4 ASC indexes: unique1, unique2, hundred, and (thousand, tenthous) -- each query has an order by to make asserting results easier @@ -315,6 +359,7 @@ CREATE DATABASE colo WITH colocation = true; SET yb_explain_hide_non_deterministic_fields = true; SET enable_bitmapscan = true; +SET yb_enable_bitmapscan = true; CREATE TABLE pk_colo (k INT PRIMARY KEY, a INT); CREATE INDEX ON pk_colo(a ASC); diff --git a/src/postgres/src/test/regress/sql/yb_bitmap_scans_distinct.sql b/src/postgres/src/test/regress/sql/yb_bitmap_scans_distinct.sql index bf1df9fc4e3d..0f12fd2286b8 100644 --- a/src/postgres/src/test/regress/sql/yb_bitmap_scans_distinct.sql +++ b/src/postgres/src/test/regress/sql/yb_bitmap_scans_distinct.sql @@ -2,6 +2,7 @@ -- test distinct bitmap scans (distinct pushdown is not supported by bitmap scans) -- SET yb_explain_hide_non_deterministic_fields = true; +SET yb_enable_bitmapscan = true; CREATE TABLE test_distinct (r1 INT, r2 INT, r3 INT, v INT, PRIMARY KEY(r1 ASC, r2 ASC, r3 ASC)) SPLIT AT VALUES ((1, 1, 500)); INSERT INTO test_distinct (SELECT 1, i%3, i, i/3 FROM GENERATE_SERIES(1, 1000) AS i); diff --git a/src/postgres/src/test/regress/sql/yb_guc.sql b/src/postgres/src/test/regress/sql/yb_guc.sql index 50e285e5d6c4..fa7f9fcf8490 100644 --- a/src/postgres/src/test/regress/sql/yb_guc.sql +++ b/src/postgres/src/test/regress/sql/yb_guc.sql @@ -45,6 +45,7 @@ CREATE TABLE test_scan (i int, j int); CREATE INDEX NONCONCURRENTLY ON test_scan (j); -- Don't add (costs off) to EXPLAIN to be able to see when disable_cost=1.0e10 -- is added. +set yb_enable_bitmapscan = on; set enable_seqscan = on; set enable_indexscan = on; set enable_indexonlyscan = on; @@ -152,3 +153,4 @@ RESET track_functions; -- cleanup RESET foo; RESET plpgsql.extra_foo_warnings; +RESET yb_enable_bitmapscan; diff --git a/src/postgres/src/test/regress/sql/yb_partition_prune.sql b/src/postgres/src/test/regress/sql/yb_partition_prune.sql index 88754050fb72..3986aa373691 100644 --- a/src/postgres/src/test/regress/sql/yb_partition_prune.sql +++ b/src/postgres/src/test/regress/sql/yb_partition_prune.sql @@ -1,3 +1,5 @@ +set yb_enable_bitmapscan = true; + create table ab (a int not null, b int not null) partition by list (a); create table ab_a2 partition of ab for values in(2) partition by list (b); create table ab_a2_b1 partition of ab_a2 for values in (1); @@ -40,5 +42,6 @@ explain (analyze, costs off, summary off, timing off) /*+ bitmapscan(ab) */ select * from ab where (ab.a = 1 OR ab.b = 1); reset enable_bitmapscan; +reset yb_enable_bitmapscan; drop table ab; diff --git a/src/postgres/src/test/regress/sql/yb_pg_select.sql b/src/postgres/src/test/regress/sql/yb_pg_select.sql index 448506397434..592def189fd7 100644 --- a/src/postgres/src/test/regress/sql/yb_pg_select.sql +++ b/src/postgres/src/test/regress/sql/yb_pg_select.sql @@ -1,6 +1,7 @@ -- -- SELECT -- +SET yb_enable_bitmapscan TO on; -- lsm index -- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 @@ -89,7 +90,7 @@ SELECT onek2.unique1, onek2.stringu1 FROM onek2 WHERE onek2.unique1 > 980 ORDER BY 1; RESET enable_seqscan; -SET enable_bitmapscan = on; +RESET enable_bitmapscan; RESET enable_sort; @@ -192,4 +193,4 @@ select unique1, unique2 from onek2 where (unique2 = 11 and stringu1 < 'B') or unique1 = 0 LIMIT ALL) ybview ORDER BY unique2; -RESET enable_bitmapscan; +RESET yb_enable_bitmapscan; diff --git a/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_init.out b/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_init.out index 7e0b3a71b6f2..3db65009312a 100644 --- a/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_init.out +++ b/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_init.out @@ -178,7 +178,7 @@ SELECT * FROM settings; parallel_tuple_cost | 0.1 | Query Tuning / Planner Cost Constants random_page_cost | 4 | Query Tuning / Planner Cost Constants seq_page_cost | 1 | Query Tuning / Planner Cost Constants - enable_bitmapscan | off | Query Tuning / Planner Method Configuration + enable_bitmapscan | on | Query Tuning / Planner Method Configuration enable_gathermerge | on | Query Tuning / Planner Method Configuration enable_hashagg | on | Query Tuning / Planner Method Configuration enable_hashjoin | on | Query Tuning / Planner Method Configuration diff --git a/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_pg_hint_plan.out b/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_pg_hint_plan.out index 3d48f51db0b8..ad08b3fc5379 100644 --- a/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_pg_hint_plan.out +++ b/src/postgres/third-party-extensions/pg_hint_plan/expected/yb_pg_pg_hint_plan.out @@ -2,6 +2,7 @@ -- . SET search_path TO public; SET client_min_messages TO log; +SET yb_enable_bitmapscan = true; \set SHOW_CONTEXT always -- In general, for postgres since t1.id and t2.id is sorted, merge joins should be optimal. -- However, since YB does not support merge join nested loop joins will be used. diff --git a/src/postgres/third-party-extensions/pg_hint_plan/sql/yb_pg_pg_hint_plan.sql b/src/postgres/third-party-extensions/pg_hint_plan/sql/yb_pg_pg_hint_plan.sql index 22ed05f7c746..b8e7906f6919 100644 --- a/src/postgres/third-party-extensions/pg_hint_plan/sql/yb_pg_pg_hint_plan.sql +++ b/src/postgres/third-party-extensions/pg_hint_plan/sql/yb_pg_pg_hint_plan.sql @@ -2,6 +2,7 @@ -- . SET search_path TO public; SET client_min_messages TO log; +SET yb_enable_bitmapscan = true; \set SHOW_CONTEXT always -- In general, for postgres since t1.id and t2.id is sorted, merge joins should be optimal.