mirror of https://github.com/postgres/postgres
Improve contrib/bloom regression test using code coverage info.
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.
This commit is contained in:
parent
bd905a0d04
commit
cf223c3bf5
|
@ -3,7 +3,7 @@ CREATE TABLE tst (
|
|||
i int4,
|
||||
t text
|
||||
);
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;
|
||||
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;
|
||||
|
@ -11,19 +11,19 @@ SET enable_indexscan=off;
|
|||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
count
|
||||
-------
|
||||
10000
|
||||
200
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
6264
|
||||
112
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
588
|
||||
13
|
||||
(1 row)
|
||||
|
||||
SET enable_seqscan=off;
|
||||
|
@ -62,61 +62,93 @@ EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
|||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
count
|
||||
-------
|
||||
10000
|
||||
200
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
6264
|
||||
112
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
588
|
||||
13
|
||||
(1 row)
|
||||
|
||||
DELETE FROM tst;
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;
|
||||
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;
|
||||
count
|
||||
-------
|
||||
10000
|
||||
200
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
6264
|
||||
112
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
588
|
||||
13
|
||||
(1 row)
|
||||
|
||||
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;
|
||||
count
|
||||
-------
|
||||
200
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
112
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
13
|
||||
(1 row)
|
||||
|
||||
VACUUM FULL tst;
|
||||
SELECT count(*) FROM tst WHERE i = 7;
|
||||
count
|
||||
-------
|
||||
10000
|
||||
200
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE t = '5';
|
||||
count
|
||||
-------
|
||||
6264
|
||||
112
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
|
||||
count
|
||||
-------
|
||||
588
|
||||
13
|
||||
(1 row)
|
||||
|
||||
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;
|
||||
opcname | amvalidate
|
||||
----------+------------
|
||||
int4_ops | t
|
||||
text_ops | t
|
||||
(2 rows)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ CREATE TABLE tst (
|
|||
t text
|
||||
);
|
||||
|
||||
INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,100000) i;
|
||||
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;
|
||||
|
@ -29,13 +29,21 @@ 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,100000) i;
|
||||
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;
|
||||
|
@ -45,3 +53,9 @@ 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;
|
||||
|
|
Loading…
Reference in New Issue