Re: Check lateral references within PHVs for memoize cache keys

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Check lateral references within PHVs for memoize cache keys
Date: 2024-07-12 03:18:10
Message-ID: 2a76386f-a104-461b-8d15-ff6c4d762925@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/11/24 16:18, Richard Guo wrote:
> On Fri, Jun 28, 2024 at 10:14 PM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
>> I got the point about Memoize over join, but as a join still calls
>> replace_nestloop_params to replace parameters in its clauses, why not to
>> invent something similar to find Memoize keys inside specific JoinPath
>> node? It is not the issue of this patch, though - but is it doable?
>
> I don't think it's impossible to do, but I'm skeptical that there's an
> easy way to identify all the cache keys for joinrels, without having
> available ppi_clauses and lateral_vars.
Ok

>
>> IMO, the code:
>> if (bms_nonempty_difference(outerPlan->chgParam, node->keyparamids))
>> cache_purge_all(node);
>>
>> is a good place to check an assertion: is it really the parent query
>> parameters that make a difference between memoize keys and node list of
>> parameters?
>
> I don't think we have enough info available here to identify which
> params within outerPlan->chgParam are from outer levels. Maybe we can
> store root->outer_params in the MemoizeState node to help with this
> assertion, but I'm not sure if it's worth the trouble.
Got it
>
> Attached is an updated version of this patch.
I'm not sure about stability of output format of AVG aggregate across
different platforms. Maybe better to return the result of comparison
between the AVG() and expected value?

--
regards, Andrei Lepikhov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2024-07-12 03:20:20 Re: Optimize WindowAgg's use of tuplestores
Previous Message Andrei Lepikhov 2024-07-12 03:05:15 Re: Removing unneeded self joins