Re: Plan caching and serialization for reuse across executions

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Xuan Chen <cx0222(at)vip(dot)qq(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Plan caching and serialization for reuse across executions
Date: 2025-08-19 06:29:43
Message-ID: b1291ef2-ba3f-4331-ba19-43ffc4537be7@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 18/8/2025 16:18, Tom Lane wrote:
> Andrei Lepikhov <lepihov(at)gmail(dot)com> writes:
>> I wouldn't recommend this obsolete version of the extension. Since the
>> QueryId was introduced, we have redesigned it extensively, with the
>> basic idea that QueryId serves as a 'query plan class' and that matching
>> parse trees provide a proof of matching incoming queries with their
>> corresponding [parameterised] plans.
>
> That's fairly scary, considering all the work that's been done to
> intentionally fuzz different queries together to make them look
> like "the same query" to pg_stat_statements. While that's fine
> for pg_stat_statements, it makes it really questionable to assume
> that QueryId is a sufficient proof of semantic equivalence.
>
> (I recall having objected to the whole concept of moving queryjumble.c
> into core on the grounds that it could not serve multiple masters.
> I think this proves my point...)
I recall that this feature is on the "we never want it" list. It was
designed using a core patch and includes a custom, more selective query
ID. That's why I recently tried to discuss the extensibility of query
IDs in several threads.
As mentioned earlier, the query ID is utilised to narrow the search
space, resulting in no more than two to three additional costly checks,
according to my research. This allows the feature to be both practical
and efficient. The accuracy of the proof is determined by a parse tree
match, along with a few additional checks on the existence of indexes
and stuff like that.
I have never considered contributing any part of this to the core, just
as the pg_hint_plan does.

--
regards, Andrei Lepikhov

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-08-19 06:32:19 Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring
Previous Message Kirill Reshke 2025-08-19 06:26:13 Re: VM corruption on standby