Re: why memoize is not used for correlated subquery - Mailing list pgsql-hackers

From Tender Wang
Subject Re: why memoize is not used for correlated subquery
Date
Msg-id CAHewXN=WJBWr6LR6S48sMQY5j9ArKGZNL6FoL2QOchnW9LLj7A@mail.gmail.com
Whole thread Raw
In response to why memoize is not used for correlated subquery  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers


Pavel Stehule <pavel.stehule@gmail.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/

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: why memoize is not used for correlated subquery
Next
From: David Rowley
Date:
Subject: Re: why memoize is not used for correlated subquery