From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
---|---|
To: | Sami Imseih <samimseih(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Nikolay Samokhvalov <nik(at)postgres(dot)ai>, Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com> |
Subject: | Re: track generic and custom plans in pg_stat_statements |
Date: | 2025-07-30 19:22:44 |
Message-ID: | b3b87daa-d610-424d-8217-bc4a47dd918c@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 7/30/25 21:05, Sami Imseih wrote:
>>> The term "NOT_SET" makes me itch a little bit, even if there is an
>>> existing parallel with OverridingKind. Perhaps your proposal is OK,
>>> still how about "UNKNOWN" instead to use as term for the default?
>> +1 to "UNKNOWN".
>
> We currently use both UNKNOWN and NOT_SET in different places.
> However, I'm okay with using UNKNOWN, and I've updated it in v16.
>
>> But generally, classification in the PlannedStmtOrigin structure seems a
>> little strange: a generic plan has a qualitative difference from any
>> custom one. And any other plan also will be generic or custom, doesn't
>> it?
>
> I am not sure I understand the reasoning here. Can you provide more details/
> specific examples?
Yep,
When building a generic plan, you don't apply any constant to the
clause, such as 'x<$1'.
That means you can't use histograms or MCV statistics when building a
custom plan. The optimiser should guess and frequently uses just a
'magic constant', like 0.05 or 0.33 for selectivity estimation. It
sometimes drastically reduces the quality of the plan. So, analysing
pg_s_s data, it would be beneficial to determine if a generic plan is
effective or not.
In practice, with this knowledge, we can access the CachedPlanSource of
the corresponding PREPARED statement via an extension and override the
decision made in 'auto' mode. Unfortunately, we cannot obtain a pointer
to plan cache entries for plans prepared by the extended protocol, but
this may be possible in the future.
So, I meant that the source of the plan is one important characteristic,
and the type (custom or generic) is another, independent characteristic
--
regards, Andrei Lepikhov
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2025-07-30 19:58:00 | Re: Support getrandom() for pg_strong_random() source |
Previous Message | Corey Huinker | 2025-07-30 19:14:58 | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |