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
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
-- Tidy up
DROP TABLE sb_1, sb_2 CASCADE;
-DROP FUNCTION extstat_small(x numeric);
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);