Re: why memoize is not used for correlated subquery

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: why memoize is not used for correlated subquery
Date: 2024-05-28 07:46:21
Message-ID: CAHewXN=WJBWr6LR6S48sMQY5j9ArKGZNL6FoL2QOchnW9LLj7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> 于2024年5月28日周二 15:31写道:

> Hi
>
>
> My question is - does memoize support subqueries? And can be enhanced to
> support this exercise without LATERAL and optimization fences?
>
>
The commit messages in memoize may answer your question:

"For now, the planner will only consider using a result cache for
parameterized nested loop joins. This works for both normal joins and
also for LATERAL type joins to subqueries. It is possible to use this
new
node for other uses in the future. For example, to cache results from
correlated subqueries. However, that's not done here due to some
difficulties obtaining a distinct estimation on the outer plan to
calculate the estimated cache hit ratio. Currently we plan the inner
plan
before planning the outer plan so there is no good way to know if a
result
cache would be useful or not since we can't estimate the number of times
the subplan will be called until the outer plan is generated."

git show b6002a796d
--
Tender Wang
OpenPie: https://en.openpie.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2024-05-28 07:48:39 Re: why memoize is not used for correlated subquery
Previous Message Pavel Stehule 2024-05-28 07:31:03 why memoize is not used for correlated subquery