Skip to content

Commit

Permalink
[BACKPORT 2024.1][#21479] YSQL: Disable bitmap scan by default
Browse files Browse the repository at this point in the history
Summary:
Original commit: b038851 / D33161
To avoid any regressions with CBO on, disable bitmap scan
until we have better defaults for costing Bitmap Scans with
CBO. Tracked by #20573
Jira: DB-10362

Test Plan:
Jenkins: urgent, test regex: .*TestPgRegress.*

```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressContribPgTrgm'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressGin'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgHintPlan'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPartitions'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPgSelect'
```

Reviewers: smishra

Reviewed By: smishra

Subscribers: yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D33187
  • Loading branch information
timothy-e committed Mar 15, 2024
1 parent 47a1fe6 commit 3528acb
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/postgres/contrib/pg_trgm/expected/yb_pg_pg_trgm.out
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ create index test2_idx_gist on test2 using gist (t gist_trgm_ops);
ERROR: index method "gist" not supported yet
HINT: See https://github.com/yugabyte/yugabyte-db/issues/1337. React with thumbs up to raise its priority
-- Check similarity threshold (bug #14202)
SET enable_bitmapscan = on;
CREATE TEMP TABLE restaurants (city text);
INSERT INTO restaurants SELECT 'Warsaw' FROM generate_series(1, 10000);
INSERT INTO restaurants SELECT 'Szczecin' FROM generate_series(1, 10000);
Expand Down Expand Up @@ -1450,3 +1451,5 @@ SELECT DISTINCT city, similarity(city, 'Warsaw'), show_limit()
--------+------------+------------
Warsaw | 1 | 0.5
(1 row)

RESET enable_bitmapscan;
4 changes: 4 additions & 0 deletions src/postgres/contrib/pg_trgm/sql/yb_pg_pg_trgm.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ create index test2_idx_gist on test2 using gist (t gist_trgm_ops);

-- Check similarity threshold (bug #14202)

SET enable_bitmapscan = on;

CREATE TEMP TABLE restaurants (city text);
INSERT INTO restaurants SELECT 'Warsaw' FROM generate_series(1, 10000);
INSERT INTO restaurants SELECT 'Szczecin' FROM generate_series(1, 10000);
Expand All @@ -113,3 +115,5 @@ SELECT DISTINCT city, similarity(city, 'Warsaw'), show_limit()
SELECT set_limit(0.5);
SELECT DISTINCT city, similarity(city, 'Warsaw'), show_limit()
FROM restaurants WHERE city % 'Warsaw';

RESET enable_bitmapscan;
2 changes: 1 addition & 1 deletion src/postgres/src/backend/utils/misc/guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ static struct config_bool ConfigureNamesBool[] =
NULL
},
&enable_bitmapscan,
true,
false,
NULL, NULL, NULL
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/expected/yb_gin.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--
-- Disable sequential scan so that bitmap index scan is always chosen.
SET enable_seqscan = off;
SET enable_bitmapscan = on;
--
-- Create temp tables because gin access method is only supported on temporary
-- tables.
Expand Down Expand Up @@ -649,3 +650,4 @@ CREATE INDEX ON vectors USING gin (v);
-- Cleanup
DROP TABLE vectors;
RESET enable_seqscan;
RESET enable_bitmapscan;
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ create index on prtx2 (c);
analyze prtx1;
analyze prtx2;
set enable_indexscan = off;
set enable_bitmapscan = on;
explain (costs off)
select * from prtx1
where not exists (select 1 from prtx2
Expand Down Expand Up @@ -1186,3 +1187,4 @@ where not exists (select 1 from prtx2
(1 row)

reset enable_indexscan;
reset enable_bitmapscan;
4 changes: 3 additions & 1 deletion src/postgres/src/test/regress/expected/yb_pg_select.out
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ SELECT onek2.unique1, onek2.stringu1 FROM onek2
(19 rows)

RESET enable_seqscan;
RESET enable_bitmapscan;
SET enable_bitmapscan = on;
RESET enable_sort;
SELECT two, stringu1, ten, string4
INTO TABLE tmp
Expand Down Expand Up @@ -693,3 +693,5 @@ LIMIT ALL) ybview ORDER BY unique2;
494 | 11
0 | 998
(2 rows)

RESET enable_bitmapscan;
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/expected/yb_reindex.out
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ SELECT i FROM tmp WHERE j = -5;
5
(1 row)

SET enable_bitmapscan = on;
EXPLAIN (costs off)
/*+IndexScan(tmp_j_idx) */
SELECT i FROM tmp WHERE j = -5;
Expand All @@ -209,6 +210,7 @@ SELECT i FROM tmp WHERE j = -5;
5
(1 row)

RESET enable_bitmapscan;
EXPLAIN (costs off)
/*+SeqScan(yb) */
SELECT i FROM yb WHERE j = -5;
Expand Down
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/expected/yb_ybgin.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--
-- Always choose index scan.
SET enable_seqscan = off;
SET enable_bitmapscan = on;
SET yb_test_ybgin_disable_cost_factor = 0.5;
--
-- Create non-temp table which uses Yugabyte storage.
Expand Down Expand Up @@ -554,3 +555,4 @@ ERROR: access method "ybgin" only supported for indexes using Yugabyte storage
-- Cleanup
DISCARD TEMP;
RESET enable_seqscan;
RESET enable_bitmapscan;
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/sql/yb_gin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

-- Disable sequential scan so that bitmap index scan is always chosen.
SET enable_seqscan = off;
SET enable_bitmapscan = on;

--
-- Create temp tables because gin access method is only supported on temporary
Expand Down Expand Up @@ -189,3 +190,4 @@ CREATE INDEX ON vectors USING gin (v);
-- Cleanup
DROP TABLE vectors;
RESET enable_seqscan;
RESET enable_bitmapscan;
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/sql/yb_pg_partition_join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ analyze prtx1;
analyze prtx2;

set enable_indexscan = off;
set enable_bitmapscan = on;

explain (costs off)
select * from prtx1
Expand All @@ -507,3 +508,4 @@ where not exists (select 1 from prtx2
and a<20 and c=91;

reset enable_indexscan;
reset enable_bitmapscan;
4 changes: 3 additions & 1 deletion src/postgres/src/test/regress/sql/yb_pg_select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 > 980 ORDER BY 1;

RESET enable_seqscan;
RESET enable_bitmapscan;
SET enable_bitmapscan = on;
RESET enable_sort;


Expand Down Expand Up @@ -191,3 +191,5 @@ SELECT * FROM (
select unique1, unique2 from onek2
where (unique2 = 11 and stringu1 < 'B') or unique1 = 0
LIMIT ALL) ybview ORDER BY unique2;

RESET enable_bitmapscan;
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/sql/yb_reindex.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ EXPLAIN (costs off)
SELECT i FROM tmp WHERE j = -5;
/*+SeqScan(tmp) */
SELECT i FROM tmp WHERE j = -5;
SET enable_bitmapscan = on;
EXPLAIN (costs off)
/*+IndexScan(tmp_j_idx) */
SELECT i FROM tmp WHERE j = -5;
/*+IndexScan(tmp_j_idx) */
SELECT i FROM tmp WHERE j = -5;
RESET enable_bitmapscan;
EXPLAIN (costs off)
/*+SeqScan(yb) */
SELECT i FROM yb WHERE j = -5;
Expand Down
2 changes: 2 additions & 0 deletions src/postgres/src/test/regress/sql/yb_ybgin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

-- Always choose index scan.
SET enable_seqscan = off;
SET enable_bitmapscan = on;
SET yb_test_ybgin_disable_cost_factor = 0.5;

--
Expand Down Expand Up @@ -179,3 +180,4 @@ CREATE INDEX ON vectors USING ybgin (v);
-- Cleanup
DISCARD TEMP;
RESET enable_seqscan;
RESET enable_bitmapscan;
Original file line number Diff line number Diff line change
Expand Up @@ -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 | on | Query Tuning / Planner Method Configuration
enable_bitmapscan | off | 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
Expand Down

0 comments on commit 3528acb

Please sign in to comment.