mirror of
https://github.com/postgres/postgres.git
synced 2025-12-10 14:22:35 +03:00
First cut at planner support for bitmap index scans. Lots to do yet,
but the code is basically working. Along the way, rewrite the entire approach to processing OR index conditions, and make it work in join cases for the first time ever. orindxpath.c is now basically obsolete, but I left it in for the time being to allow easy comparison testing against the old implementation.
This commit is contained in:
@@ -131,8 +131,10 @@ ALTER INDEX tmp_onek_unique1 RENAME TO onek_unique1;
|
||||
-- renaming views
|
||||
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
||||
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
||||
-- analyze to ensure we get an indexscan here
|
||||
-- hack to ensure we get an indexscan here
|
||||
ANALYZE tenk1;
|
||||
set enable_seqscan to off;
|
||||
set enable_bitmapscan to off;
|
||||
-- 5 values, sorted
|
||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
unique1
|
||||
@@ -144,6 +146,8 @@ SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
4
|
||||
(5 rows)
|
||||
|
||||
reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
DROP VIEW tmp_view_new;
|
||||
-- toast-like relation name
|
||||
alter table stud_emp rename to pg_toast_stud_emp;
|
||||
|
||||
@@ -367,6 +367,7 @@ insert into arr_tbl values ('{2,3,4}');
|
||||
insert into arr_tbl values ('{1,5,3}');
|
||||
insert into arr_tbl values ('{1,2,10}');
|
||||
set enable_seqscan to off;
|
||||
set enable_bitmapscan to off;
|
||||
select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
|
||||
f1
|
||||
----------
|
||||
@@ -376,6 +377,8 @@ select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
|
||||
|
||||
-- note: if above select doesn't produce the expected tuple order,
|
||||
-- then you didn't get an indexscan plan, and something is busted.
|
||||
reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
-- test [not] (like|ilike) (any|all) (...)
|
||||
select 'foo' like any (array['%a', '%o']); -- t
|
||||
?column?
|
||||
|
||||
@@ -11,6 +11,8 @@ SHOW stats_start_collector; -- must be on
|
||||
on
|
||||
(1 row)
|
||||
|
||||
-- XXX stopgap until we figure out how bitmap scans should be counted
|
||||
SET enable_bitmapscan = off;
|
||||
-- save counters
|
||||
CREATE TEMP TABLE prevstats AS
|
||||
SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
|
||||
|
||||
@@ -171,10 +171,16 @@ ALTER INDEX tmp_onek_unique1 RENAME TO onek_unique1;
|
||||
-- renaming views
|
||||
CREATE VIEW tmp_view (unique1) AS SELECT unique1 FROM tenk1;
|
||||
ALTER TABLE tmp_view RENAME TO tmp_view_new;
|
||||
-- analyze to ensure we get an indexscan here
|
||||
|
||||
-- hack to ensure we get an indexscan here
|
||||
ANALYZE tenk1;
|
||||
set enable_seqscan to off;
|
||||
set enable_bitmapscan to off;
|
||||
-- 5 values, sorted
|
||||
SELECT unique1 FROM tenk1 WHERE unique1 < 5;
|
||||
reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
|
||||
DROP VIEW tmp_view_new;
|
||||
-- toast-like relation name
|
||||
alter table stud_emp rename to pg_toast_stud_emp;
|
||||
|
||||
@@ -178,10 +178,14 @@ insert into arr_tbl values ('{1,2,3}');
|
||||
insert into arr_tbl values ('{2,3,4}');
|
||||
insert into arr_tbl values ('{1,5,3}');
|
||||
insert into arr_tbl values ('{1,2,10}');
|
||||
|
||||
set enable_seqscan to off;
|
||||
set enable_bitmapscan to off;
|
||||
select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}';
|
||||
-- note: if above select doesn't produce the expected tuple order,
|
||||
-- then you didn't get an indexscan plan, and something is busted.
|
||||
reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
|
||||
-- test [not] (like|ilike) (any|all) (...)
|
||||
select 'foo' like any (array['%a', '%o']); -- t
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
-- conditio sine qua non
|
||||
SHOW stats_start_collector; -- must be on
|
||||
|
||||
-- XXX stopgap until we figure out how bitmap scans should be counted
|
||||
SET enable_bitmapscan = off;
|
||||
|
||||
-- save counters
|
||||
CREATE TEMP TABLE prevstats AS
|
||||
SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
|
||||
|
||||
Reference in New Issue
Block a user