Re: Is it useful to record whether plans are generic or custom?

torikoshia <torikoshia@oss.nttdata.com>

From: torikoshia <torikoshia@oss.nttdata.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>, Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, legrand legrand <legrand_legrand@hotmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2020-12-04T06:03:25Z
Lists: pgsql-hackers
On 2020-12-04 14:29, Fujii Masao wrote:
> On 2020/11/30 15:24, Tatsuro Yamada wrote:
>> Hi Torikoshi-san,
>> 
>> 
>>> In this patch, exposing new columns is mandatory, but I think
>>> it's better to make it optional by adding a GUC something
>>> like 'pgss.track_general_custom_plans.
>>> 
>>> I also feel it makes the number of columns too many.
>>> Just adding the total time may be sufficient.
>> 
>> 
>> I think this feature is useful for DBA. So I hope that it gets
>> committed to PG14. IMHO, many columns are Okay because DBA can
>> select specific columns by their query.
>> Therefore, it would be better to go with the current design.
> 
> But that design may waste lots of memory. No? For example, when
> plan_cache_mode=force_custom_plan, the memory used for the columns
> for generic plans is not used.
> 

Yeah.

ISTM now that creating pg_stat_statements_xxx views
both for generic andcustom plans is better than my PoC patch.

And I'm also struggling with the following.

| However, I also began to wonder how effective it would be to just
| distinguish between generic and custom plans.  Custom plans can
| include all sorts of plans. and thinking cache validation, generic
| plans can also include various plans.

| Considering this, I'm starting to feel that it would be better to
| not just keeping whether generic or cutom but the plan itself as
| discussed in the below thread.


Yamada-san,

Do you think it's effective just distinguish between generic
and custom plans?

Regards,



Commits

  1. Add generic_plans and custom_plans fields into pg_prepared_statements.