Re: Hybrid Hash/Nested Loop joins and caching results from subplans
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>,
Andres Freund <andres@anarazel.de>
Date: 2020-08-19T22:04:10Z
Lists: pgsql-hackers
On Wed, 19 Aug 2020 at 16:18, Pavel Stehule <pavel.stehule@gmail.com> wrote: > > > > st 19. 8. 2020 v 5:48 odesílatel David Rowley <dgrowleyml@gmail.com> napsal: >> Current method: >> >> regression=# explain (analyze, costs off, timing off, summary off) >> select twenty, (select count(*) from tenk1 t2 where t1.twenty = >> t2.twenty) from tenk1 t1; >> QUERY PLAN >> --------------------------------------------------------------------- >> Seq Scan on tenk1 t1 (actual rows=10000 loops=1) >> SubPlan 1 >> -> Result Cache (actual rows=1 loops=10000) >> Cache Key: t1.twenty >> Hits: 9980 Misses: 20 Evictions: 0 Overflows: 0 >> -> Aggregate (actual rows=1 loops=20) >> -> Seq Scan on tenk1 t2 (actual rows=500 loops=20) >> Filter: (t1.twenty = twenty) >> Rows Removed by Filter: 9500 >> (9 rows) >> >> Andres' suggestion: >> >> regression=# explain (analyze, costs off, timing off, summary off) >> select twenty, (select count(*) from tenk1 t2 where t1.twenty = >> t2.twenty) from tenk1 t1; >> QUERY PLAN >> --------------------------------------------------------------------- >> Seq Scan on tenk1 t1 (actual rows=10000 loops=1) >> SubPlan 1 >> Cache Key: t1.twenty Hits: 9980 Misses: 20 Evictions: 0 Overflows: 0 >> -> Aggregate (actual rows=1 loops=20) >> -> Seq Scan on tenk1 t2 (actual rows=500 loops=20) >> Filter: (t1.twenty = twenty) >> Rows Removed by Filter: 9500 >> (7 rows) > I didn't do performance tests, that should be necessary, but I think Andres' variant is a little bit more readable. Thanks for chiming in on this. I was just wondering about the readability part and what makes the one with the Result Cache node less readable? I can think of a couple of reasons you might have this view and just wanted to double-check what it is. David
Commits
-
Add Result Cache executor node (take 2)
- 9eacee2e62d8 14.0 landed
-
Add Result Cache executor node
- b6002a796dc0 14.0 landed
-
Allow estimate_num_groups() to pass back further details about the estimation
- ed934d4fa30f 14.0 landed
-
Allow users of simplehash.h to perform direct deletions
- ff53d7b159b9 14.0 landed
-
Cache if PathTarget and RestrictInfos contain volatile functions
- f58b230ed0db 14.0 landed
-
Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar.
- 55dc86eca70b 14.0 cited