mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-21 15:23:24 +02:00
Originally, this test created a 100000-row test table, which made it run rather slowly compared to other contrib tests. Investigation with gcov showed that we got no further improvement in code coverage after the first 700 or so rows, making the large table 99% a waste of time. Cut it back to 2000 rows to fix the runtime problem and still leave some headroom for testing behaviors that may appear later. A closer look at the gcov results showed that the main coverage omissions in contrib/bloom occurred because the test never filled more than one entry in the notFullPage array; which is unsurprising because it exercised index cleanup only in the scenario of complete table deletion, allowing every page in the index to become deleted rather than not-full. Add testing that allows the not-full path to be exercised as well. Also, test the amvalidate function, because blvalidate.c had zero coverage without that, and besides it's a good idea to check for mistakes in the bloom opclass definitions.
62 lines
1.7 KiB
SQL
62 lines
1.7 KiB
SQL
CREATE EXTENSION bloom;
|
|
|
|
CREATE TABLE tst (
|
|
i int4,
|
|
t text
|
|
);
|
|
|
|
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
|
CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);
|
|
|
|
SET enable_seqscan=on;
|
|
SET enable_bitmapscan=off;
|
|
SET enable_indexscan=off;
|
|
|
|
SELECT count(*) FROM tst WHERE i = 7;
|
|
SELECT count(*) FROM tst WHERE t = '5';
|
|
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|
|
|
SET enable_seqscan=off;
|
|
SET enable_bitmapscan=on;
|
|
SET enable_indexscan=on;
|
|
|
|
EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE i = 7;
|
|
EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE t = '5';
|
|
EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|
|
|
SELECT count(*) FROM tst WHERE i = 7;
|
|
SELECT count(*) FROM tst WHERE t = '5';
|
|
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|
|
|
DELETE FROM tst;
|
|
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
|
VACUUM ANALYZE tst;
|
|
|
|
SELECT count(*) FROM tst WHERE i = 7;
|
|
SELECT count(*) FROM tst WHERE t = '5';
|
|
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|
|
|
DELETE FROM tst WHERE i > 1 OR t = '5';
|
|
VACUUM tst;
|
|
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
|
|
|
|
SELECT count(*) FROM tst WHERE i = 7;
|
|
SELECT count(*) FROM tst WHERE t = '5';
|
|
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|
|
|
VACUUM FULL tst;
|
|
|
|
SELECT count(*) FROM tst WHERE i = 7;
|
|
SELECT count(*) FROM tst WHERE t = '5';
|
|
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|
|
|
RESET enable_seqscan;
|
|
RESET enable_bitmapscan;
|
|
RESET enable_indexscan;
|
|
|
|
-- Run amvalidator function on our opclasses
|
|
SELECT opcname, amvalidate(opc.oid)
|
|
FROM pg_opclass opc JOIN pg_am am ON am.oid = opcmethod
|
|
WHERE amname = 'bloom'
|
|
ORDER BY 1;
|