Skip to content

Commit 3d48654

Browse files
committed
Improve inefficient regexes in vacuumdb TAP test.
The regexes used in 102_vacuumdb_stages.pl to check the postmaster log for expected output contained several places with ".*.*", which is underdetermined and can cause exponential runtime growth in Perl's regex matcher (since it's not bright enough not to waste time seeing whether different splits of the same substring would allow a match). We were fortunate that the amount of text in the postmaster log was generally not enough to make the runtime go to the moon; although commit 6271fce had been on the hairy edge of an obvious problem, thanks to its increasing the default log verbosity to DEBUG1. Experimentation shows that anyone who tried to run this test case with an even higher log verbosity would have been in for serious pain. But even at default logging level, fixing this saves several hundred ms on my workstation, more on slower buildfarm members. Remove the extra ".*"s, restoring more-or-less-linear matching speed. Back-patch to 9.4 where the test case was added, mostly in case anyone tries to do related debugging in a back branch. Discussion: https://postgr.es/m/32459.1525657786@sss.pgh.pa.us
1 parent 364998d commit 3d48654

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/bin/scripts/t/102_vacuumdb_stages.pl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88

99
issues_sql_like(
1010
[ 'vacuumdb', '--analyze-in-stages', 'postgres' ],
11-
qr/.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
12-
.*statement:\ ANALYZE.*
11+
qr/statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
12+
.*statement:\ ANALYZE
1313
.*statement:\ SET\ default_statistics_target=10;\ RESET\ vacuum_cost_delay;
14-
.*statement:\ ANALYZE.*
14+
.*statement:\ ANALYZE
1515
.*statement:\ RESET\ default_statistics_target;
1616
.*statement:\ ANALYZE/sx,
1717
'analyze three times');
1818

1919

2020
issues_sql_like(
2121
[ 'vacuumdb', '--analyze-in-stages', '--all' ],
22-
qr/.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
23-
.*statement:\ ANALYZE.*
22+
qr/statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
23+
.*statement:\ ANALYZE
2424
.*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0;
25-
.*statement:\ ANALYZE.*
25+
.*statement:\ ANALYZE
2626
.*statement:\ SET\ default_statistics_target=10;\ RESET\ vacuum_cost_delay;
27-
.*statement:\ ANALYZE.*
27+
.*statement:\ ANALYZE
2828
.*statement:\ SET\ default_statistics_target=10;\ RESET\ vacuum_cost_delay;
29-
.*statement:\ ANALYZE.*
29+
.*statement:\ ANALYZE
3030
.*statement:\ RESET\ default_statistics_target;
31-
.*statement:\ ANALYZE.*
31+
.*statement:\ ANALYZE
3232
.*statement:\ RESET\ default_statistics_target;
3333
.*statement:\ ANALYZE/sx,
3434
'analyze more than one database in stages');

0 commit comments

Comments
 (0)