aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-04-10 13:12:24 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-04-10 13:12:24 -0400
commitcf223c3bf5ba16232147c66b5fef4037aafe747c (patch)
tree3f801d8612eb6922f2344e0c18966b06c654be39
parentbd905a0d0416628b4aef153463c1f5e5b80b3e96 (diff)
downloadpostgresql-cf223c3bf5ba16232147c66b5fef4037aafe747c.tar.gz
postgresql-cf223c3bf5ba16232147c66b5fef4037aafe747c.zip
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.
-rw-r--r--contrib/bloom/expected/bloom.out60
-rw-r--r--contrib/bloom/sql/bloom.sql18
2 files changed, 62 insertions, 16 deletions
diff --git a/contrib/bloom/expected/bloom.out b/contrib/bloom/expected/bloom.out
index 5e8269faf35..71700efd5ae 100644
--- a/contrib/bloom/expected/bloom.out
+++ b/contrib/bloom/expected/bloom.out
@@ -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)
+
diff --git a/contrib/bloom/sql/bloom.sql b/contrib/bloom/sql/bloom.sql
index f9d0ad45d98..e9174828fe6 100644
--- a/contrib/bloom/sql/bloom.sql
+++ b/contrib/bloom/sql/bloom.sql
@@ -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;