-- Generate enough data that we can test the lossy bitmaps.
-- There's 55 tuples per page in the table. 53 is just -- below 55, so that an index scan with qual a = constant -- will return at least one hit per page. 59 is just above -- 55, so that an index scan with qual b = constant will return -- hits on most but not all pages. 53 and 59 are prime, so that -- there's a maximum number of a,b combinations in the table. -- That allows us to test all the different combinations of -- lossy and non-lossy pages with the minimum amount of data
CREATETABLE bmscantest (a int, b int, t text) WITH (autovacuum_enabled = false);
INSERTINTO bmscantest SELECT (r%53), (r%59), 'foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' FROM generate_series(1,70000) r;
CREATEINDEX i_bmtest_a ON bmscantest(a); CREATEINDEX i_bmtest_b ON bmscantest(b);
-- We want to use bitmapscans. With default settings, the planner currently -- chooses a bitmap scan for the queries below anyway, but let's make sure. set enable_indexscan=false; set enable_seqscan=false;
-- Lower work_mem to trigger use of lossy bitmaps set work_mem = 64;
-- Test bitmap-and without the skip fetch optimization. SELECT count(*) FROM bmscantest WHERE a = 1AND b = 1;
-- Test that we return correct results when using the skip fetch optimization -- VACUUM FREEZE will set all the pages in the relation all-visible, enabling -- the optimization.
VACUUM (FREEZE) bmscantest;
SELECT count(*) FROM bmscantest WHERE a = 1AND b = 1;
-- Test bitmap-or. SELECT count(*) FROM bmscantest WHERE a = 1OR b = 1;
-- clean up DROPTABLE bmscantest;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.