From a3a836fb5e51183eae624d43225279306c2285b8 Mon Sep 17 00:00:00 2001 From: David Rowley Date: Sat, 27 Jan 2024 11:17:35 +1300 Subject: [PATCH] Attempt to fix newly added Memoize regression test Both drongo and fairywren seem not to like a new regression test added by 2cca95e17. These machines show a different number of actual rows in the EXPLAIN ANALYZE output. Since the number of actual rows is divided by the number of loops, I suspect this might be due to some platform dependant rounding behavior as the total row count is 5 and the number of loops is 2. drongo and fairywren seem to be calculating that 5.0 / 2.0 is 3, whereas most other machines think the answer is 2. Here we tweak the test query's WHERE clause so it's 4.0 / 2.0 instead. There shouldn't be too much wiggle room for platform dependant-behavior to be a factor with those numbers. Reported-by: Tom Lane Discussion: https://postgr.es/m/1035225.1706301718%40sss.pgh.pa.us --- src/test/regress/expected/memoize.out | 12 ++++++------ src/test/regress/sql/memoize.sql | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/regress/expected/memoize.out b/src/test/regress/expected/memoize.out index 17bb3c8661..cf6886a288 100644 --- a/src/test/regress/expected/memoize.out +++ b/src/test/regress/expected/memoize.out @@ -96,14 +96,14 @@ WHERE t1.unique1 < 1000; SELECT explain_memoize(' SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN LATERAL ( - SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 5 OFFSET 0 + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 ) t2 ON t1.two = t2.two WHERE t1.unique1 < 10;', false); explain_memoize ---------------------------------------------------------------------------------------------- Aggregate (actual rows=1 loops=N) - -> Nested Loop Left Join (actual rows=25 loops=N) + -> Nested Loop Left Join (actual rows=20 loops=N) -> Index Scan using tenk1_unique1 on tenk1 t1 (actual rows=10 loops=N) Index Cond: (unique1 < 10) -> Memoize (actual rows=2 loops=N) @@ -113,20 +113,20 @@ WHERE t1.unique1 < 10;', false); -> Subquery Scan on t2 (actual rows=2 loops=N) Filter: (t1.two = t2.two) Rows Removed by Filter: 2 - -> Index Scan using tenk1_unique1 on tenk1 t2_1 (actual rows=5 loops=N) - Index Cond: (unique1 < 5) + -> Index Scan using tenk1_unique1 on tenk1 t2_1 (actual rows=4 loops=N) + Index Cond: (unique1 < 4) (13 rows) -- And check we get the expected results. SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN LATERAL ( - SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 5 OFFSET 0 + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 ) t2 ON t1.two = t2.two WHERE t1.unique1 < 10; count | avg -------+------------------------ - 25 | 0.40000000000000000000 + 20 | 0.50000000000000000000 (1 row) -- Reduce work_mem and hash_mem_multiplier so that we see some cache evictions diff --git a/src/test/regress/sql/memoize.sql b/src/test/regress/sql/memoize.sql index 3793c28593..1f4ab0ba3b 100644 --- a/src/test/regress/sql/memoize.sql +++ b/src/test/regress/sql/memoize.sql @@ -61,7 +61,7 @@ WHERE t1.unique1 < 1000; SELECT explain_memoize(' SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN LATERAL ( - SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 5 OFFSET 0 + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 ) t2 ON t1.two = t2.two WHERE t1.unique1 < 10;', false); @@ -69,7 +69,7 @@ WHERE t1.unique1 < 10;', false); -- And check we get the expected results. SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN LATERAL ( - SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 5 OFFSET 0 + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 ) t2 ON t1.two = t2.two WHERE t1.unique1 < 10;