1
-- Test bitmap AND and OR
4
-- Generate enough data that we can test the lossy bitmaps.
6
-- There's 55 tuples per page in the table. 53 is just
7
-- below 55, so that an index scan with qual a = constant
8
-- will return at least one hit per page. 59 is just above
9
-- 55, so that an index scan with qual b = constant will return
10
-- hits on most but not all pages. 53 and 59 are prime, so that
11
-- there's a maximum number of a,b combinations in the table.
12
-- That allows us to test all the different combinations of
13
-- lossy and non-lossy pages with the minimum amount of data
15
CREATE TABLE bmscantest (a int, b int, t text);
17
INSERT INTO bmscantest
18
SELECT (r%53), (r%59), 'foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo'
19
FROM generate_series(1,70000) r;
21
CREATE INDEX i_bmtest_a ON bmscantest(a);
22
CREATE INDEX i_bmtest_b ON bmscantest(b);
24
-- We want to use bitmapscans. With default settings, the planner currently
25
-- chooses a bitmap scan for the queries below anyway, but let's make sure.
26
set enable_indexscan=false;
27
set enable_seqscan=false;
29
-- Lower work_mem to trigger use of lossy bitmaps
34
SELECT count(*) FROM bmscantest WHERE a = 1 AND b = 1;
37
SELECT count(*) FROM bmscantest WHERE a = 1 OR b = 1;
41
DROP TABLE bmscantest;