Re: Check lateral references within PHVs for memoize cache keys
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Paul A Jungwirth <pj@illuminatedcomputing.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-07-13T09:29:42Z
Lists: pgsql-hackers
On Sun, Jul 9, 2023 at 12:17 PM David Rowley <dgrowleyml@gmail.com> wrote:
> I just pushed a fix for this. Thanks for reporting it.
BTW, I noticed a typo in the comment inside paraminfo_get_equal_hashops.
foreach(lc, innerrel->lateral_vars)
{
Node *expr = (Node *) lfirst(lc);
TypeCacheEntry *typentry;
/* Reject if there are any volatile functions in PHVs */
if (contain_volatile_functions(expr))
{
list_free(*operators);
list_free(*param_exprs);
return false;
}
The expressions in RelOptInfo.lateral_vars are not necessarily from
PHVs. For instance
explain (costs off)
select * from t t1 join
lateral (select * from t t2 where t1.a = t2.a offset 0) on true;
QUERY PLAN
----------------------------------
Nested Loop
-> Seq Scan on t t1
-> Memoize
Cache Key: t1.a
Cache Mode: binary
-> Seq Scan on t t2
Filter: (t1.a = a)
(7 rows)
The lateral Var 't1.a' comes from the lateral subquery, not PHV.
This seems a typo from 63e4f13d. How about we change it to the below?
- /* Reject if there are any volatile functions in PHVs */
+ /* Reject if there are any volatile functions in lateral vars */
Thanks
Richard
Commits
-
Check lateral references within PHVs for memoize cache keys
- 069d0ff0226b 18.0 landed
-
Doc: update old reference to "result cache"
- 571377dfb83d 14.9 landed
- 3883ef3236e5 15.4 landed
- 6d8b5f49f0e1 16.0 landed
- c23e7ea4d6a4 17.0 landed