ln := regexp_replace(ln, 'Evictions: \d+', 'Evictions: N');
ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N');
ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N');
+ ln := regexp_replace(ln, 'loops=\d+', 'loops=N');
return next ln;
end loop;
end;
-- Ensure we get a result cache on the inner side of the nested loop
SET enable_hashjoin TO off;
SET enable_bitmapscan TO off;
+-- force_parallel_mode = regress can cause some instability in EXPLAIN ANALYZE
+-- output, so let's ensure that we turn it off.
+SET force_parallel_mode TO off;
SELECT explain_resultcache('
SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1
INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty
WHERE t2.unique1 < 1000;', false);
- explain_resultcache
---------------------------------------------------------------------------------------------
- Aggregate (actual rows=1 loops=1)
- -> Nested Loop (actual rows=1000 loops=1)
- -> Seq Scan on tenk1 t2 (actual rows=1000 loops=1)
+ explain_resultcache
+-------------------------------------------------------------------------------------------
+ Aggregate (actual rows=1 loops=N)
+ -> Nested Loop (actual rows=1000 loops=N)
+ -> Seq Scan on tenk1 t2 (actual rows=1000 loops=N)
Filter: (unique1 < 1000)
Rows Removed by Filter: 9000
- -> Result Cache (actual rows=1 loops=1000)
+ -> Result Cache (actual rows=1 loops=N)
Cache Key: t2.twenty
Hits: 980 Misses: 20 Evictions: Zero Overflows: 0 Memory Usage: NkB
- -> Index Only Scan using tenk1_unique1 on tenk1 t1 (actual rows=1 loops=20)
+ -> Index Only Scan using tenk1_unique1 on tenk1 t1 (actual rows=1 loops=N)
Index Cond: (unique1 = t2.twenty)
Heap Fetches: N
(11 rows)
SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1,
LATERAL (SELECT t2.unique1 FROM tenk1 t2 WHERE t1.twenty = t2.unique1) t2
WHERE t1.unique1 < 1000;', false);
- explain_resultcache
---------------------------------------------------------------------------------------------
- Aggregate (actual rows=1 loops=1)
- -> Nested Loop (actual rows=1000 loops=1)
- -> Seq Scan on tenk1 t1 (actual rows=1000 loops=1)
+ explain_resultcache
+-------------------------------------------------------------------------------------------
+ Aggregate (actual rows=1 loops=N)
+ -> Nested Loop (actual rows=1000 loops=N)
+ -> Seq Scan on tenk1 t1 (actual rows=1000 loops=N)
Filter: (unique1 < 1000)
Rows Removed by Filter: 9000
- -> Result Cache (actual rows=1 loops=1000)
+ -> Result Cache (actual rows=1 loops=N)
Cache Key: t1.twenty
Hits: 980 Misses: 20 Evictions: Zero Overflows: 0 Memory Usage: NkB
- -> Index Only Scan using tenk1_unique1 on tenk1 t2 (actual rows=1 loops=20)
+ -> Index Only Scan using tenk1_unique1 on tenk1 t2 (actual rows=1 loops=N)
Index Cond: (unique1 = t1.twenty)
Heap Fetches: N
(11 rows)
SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1
INNER JOIN tenk1 t2 ON t1.unique1 = t2.thousand
WHERE t2.unique1 < 1200;', true);
- explain_resultcache
-----------------------------------------------------------------------------------------------
- Aggregate (actual rows=1 loops=1)
- -> Nested Loop (actual rows=1200 loops=1)
- -> Seq Scan on tenk1 t2 (actual rows=1200 loops=1)
+ explain_resultcache
+-------------------------------------------------------------------------------------------
+ Aggregate (actual rows=1 loops=N)
+ -> Nested Loop (actual rows=1200 loops=N)
+ -> Seq Scan on tenk1 t2 (actual rows=1200 loops=N)
Filter: (unique1 < 1200)
Rows Removed by Filter: 8800
- -> Result Cache (actual rows=1 loops=1200)
+ -> Result Cache (actual rows=1 loops=N)
Cache Key: t2.thousand
Hits: N Misses: N Evictions: N Overflows: 0 Memory Usage: NkB
- -> Index Only Scan using tenk1_unique1 on tenk1 t1 (actual rows=1 loops=1028)
+ -> Index Only Scan using tenk1_unique1 on tenk1 t1 (actual rows=1 loops=N)
Index Cond: (unique1 = t2.thousand)
Heap Fetches: N
(11 rows)
RESET enable_mergejoin;
RESET work_mem;
+RESET force_parallel_mode;
RESET enable_bitmapscan;
RESET enable_hashjoin;
-- Test parallel plans with Result Cache.
ln := regexp_replace(ln, 'Evictions: \d+', 'Evictions: N');
ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N');
ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N');
+ ln := regexp_replace(ln, 'loops=\d+', 'loops=N');
return next ln;
end loop;
end;
-- Ensure we get a result cache on the inner side of the nested loop
SET enable_hashjoin TO off;
SET enable_bitmapscan TO off;
+-- force_parallel_mode = regress can cause some instability in EXPLAIN ANALYZE
+-- output, so let's ensure that we turn it off.
+SET force_parallel_mode TO off;
SELECT explain_resultcache('
SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1
INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty
WHERE t2.unique1 < 1200;', true);
RESET enable_mergejoin;
RESET work_mem;
+RESET force_parallel_mode;
RESET enable_bitmapscan;
RESET enable_hashjoin;