Attempt to fix newly added Memoize regression test
authorDavid Rowley
Fri, 26 Jan 2024 22:17:35 +0000 (11:17 +1300)
committerDavid Rowley
Fri, 26 Jan 2024 22:17:35 +0000 (11:17 +1300)
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
src/test/regress/sql/memoize.sql

index 17bb3c8661dd3ba18574a29958925d4b56062263..cf6886a288de1dd91a80e3a0dc563bdaa9316d2b 100644 (file)
@@ -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
index 3793c28593c4897940bd3f9fdc9a00dfd6ce2407..1f4ab0ba3bb20b94a8e7a4793d454a162b5fe1d2 100644 (file)
@@ -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;