diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2025-12-03 13:23:45 -0500 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2025-12-03 13:23:50 -0500 |
| commit | 8d61228717e619b90b8ebd1d219d006b920e00e5 (patch) | |
| tree | bcec1377dc325d5cdaa98c8fc987edaeea81b3b8 /src | |
| parent | 7b81be9b42678c7ab69c3e8f565172f1d8d9e86f (diff) | |
Make stats_ext test faster under cache-clobbering test conditions.
Commit 1eccb9315 added a test case that will cause a large number
of evaluations of a plpgsql function. With -DCLOBBER_CACHE_ALWAYS,
that takes an unreasonable amount of time (hours) because the
function's cache entries are repeatedly deleted and rebuilt.
That doesn't add any useful test coverage --- other test cases
already exercise plpgsql well enough --- and it's not part of what
this test intended to cover. We can get the same planner coverage,
if not more, by making the test directly invoke numeric_lt().
Reported-by: Tomas Vondra <tomas@vondra.me>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/baf1ae02-83bd-4f5d-872a-1d04f11a9073@vondra.me
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/regress/expected/stats_ext.out | 10 | ||||
| -rw-r--r-- | src/test/regress/sql/stats_ext.sql | 11 |
2 files changed, 6 insertions, 15 deletions
diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index 5a4077f8ed5..eb70ea5a2ee 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -3786,18 +3786,15 @@ SELECT FROM sb_1 LEFT JOIN sb_2 RESET enable_nestloop; RESET enable_mergejoin; -- Check that we can use statistics on a bool-valued function. -CREATE FUNCTION extstat_small(x numeric) RETURNS bool -STRICT IMMUTABLE LANGUAGE plpgsql -AS $$ BEGIN RETURN x < 1; END $$; -SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE extstat_small(y)'); +SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE numeric_lt(y, 1.0)'); estimated | actual -----------+-------- 3333 | 196 (1 row) -CREATE STATISTICS extstat_sb_2_small ON extstat_small(y) FROM sb_2; +CREATE STATISTICS extstat_sb_2_small ON numeric_lt(y, 1.0) FROM sb_2; ANALYZE sb_2; -SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE extstat_small(y)'); +SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE numeric_lt(y, 1.0)'); estimated | actual -----------+-------- 196 | 196 @@ -3805,4 +3802,3 @@ SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE extstat_small(y)'); -- Tidy up DROP TABLE sb_1, sb_2 CASCADE; -DROP FUNCTION extstat_small(x numeric); diff --git a/src/test/regress/sql/stats_ext.sql b/src/test/regress/sql/stats_ext.sql index 94e2139c504..3f8e03f28a0 100644 --- a/src/test/regress/sql/stats_ext.sql +++ b/src/test/regress/sql/stats_ext.sql @@ -1855,17 +1855,12 @@ RESET enable_nestloop; RESET enable_mergejoin; -- Check that we can use statistics on a bool-valued function. -CREATE FUNCTION extstat_small(x numeric) RETURNS bool -STRICT IMMUTABLE LANGUAGE plpgsql -AS $$ BEGIN RETURN x < 1; END $$; +SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE numeric_lt(y, 1.0)'); -SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE extstat_small(y)'); - -CREATE STATISTICS extstat_sb_2_small ON extstat_small(y) FROM sb_2; +CREATE STATISTICS extstat_sb_2_small ON numeric_lt(y, 1.0) FROM sb_2; ANALYZE sb_2; -SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE extstat_small(y)'); +SELECT * FROM check_estimated_rows('SELECT * FROM sb_2 WHERE numeric_lt(y, 1.0)'); -- Tidy up DROP TABLE sb_1, sb_2 CASCADE; -DROP FUNCTION extstat_small(x numeric); |
