Skip to content

Commit 4072d91

Browse files
committed
Avoid unexpected slowdown in vacuum regression test.
I noticed the "vacuum" regression test taking really significantly longer than it used to on a slow machine. Investigation pointed the finger at commit e415b46, which added creation of an index using an extremely expensive index function. That function was evidently meant to be applied only twice ... but the test re-used an existing test table, which up till a couple lines before that had had over two thousand rows. Depending on timing of the concurrent regression tests, the intervening VACUUMs might have been unable to remove those recently-dead rows, and then the index build would need to create index entries for them too, leading to the wrap_do_analyze() function being executed 2000+ times not twice. Avoid this by using a different table that is guaranteed to have only the intended two rows in it. Back-patch to 9.0, like the commit that created the problem.
1 parent 8f2d99b commit 4072d91

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/test/regress/expected/vacuum.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
6565
AS 'ANALYZE pg_am';
6666
CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
6767
AS 'SELECT $1 FROM do_analyze()';
68-
CREATE INDEX ON vactst(wrap_do_analyze(i));
69-
INSERT INTO vactst VALUES (1), (2);
70-
ANALYZE vactst;
68+
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
69+
INSERT INTO vaccluster VALUES (1), (2);
70+
ANALYZE vaccluster;
7171
ERROR: ANALYZE cannot be executed from VACUUM or ANALYZE
7272
CONTEXT: SQL function "do_analyze" statement 1
7373
SQL function "wrap_do_analyze" statement 1
7474
VACUUM FULL pg_am;
7575
VACUUM FULL pg_class;
7676
VACUUM FULL pg_database;
7777
VACUUM FULL vaccluster;
78-
VACUUM FULL vactst;
7978
ERROR: ANALYZE cannot be executed from VACUUM or ANALYZE
8079
CONTEXT: SQL function "do_analyze" statement 1
8180
SQL function "wrap_do_analyze" statement 1
81+
VACUUM FULL vactst;
8282
DROP TABLE vaccluster;
8383
DROP TABLE vactst;

src/test/regress/sql/vacuum.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
5050
AS 'ANALYZE pg_am';
5151
CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
5252
AS 'SELECT $1 FROM do_analyze()';
53-
CREATE INDEX ON vactst(wrap_do_analyze(i));
54-
INSERT INTO vactst VALUES (1), (2);
55-
ANALYZE vactst;
53+
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
54+
INSERT INTO vaccluster VALUES (1), (2);
55+
ANALYZE vaccluster;
5656

5757
VACUUM FULL pg_am;
5858
VACUUM FULL pg_class;

0 commit comments

Comments
 (0)