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

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: ikedamsh(at)oss(dot)nttdata(dot)com, atorik(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org, legrand_legrand(at)hotmail(dot)com, tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp
Subject: Re: Is it useful to record whether plans are generic or custom?
Date: 2020-07-06 13:16:18
Message-ID: 5524f151-33ae-7de9-0f59-3e9db136dc27@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020/06/11 14:59, torikoshia wrote:
> On 2020-06-10 18:00, Kyotaro Horiguchi wrote:
>
>>
>> +    TupleDescInitEntry(tupdesc, (AttrNumber) 8, "last_plan",
>>
>> This could be a problem if we showed the last plan in this view.  I
>> think "last_plan_type" would be better.
>>
>> +            if (prep_stmt->plansource->last_plan_type == PLAN_CACHE_TYPE_CUSTOM)
>> +                values[7] = CStringGetTextDatum("custom");
>> +            else if (prep_stmt->plansource->last_plan_type == PLAN_CACHE_TYPE_GENERIC)
>> +                values[7] = CStringGetTextDatum("generic");
>> +            else
>> +                nulls[7] = true;
>>
>> Using swith-case prevents future additional type (if any) from being
>> unhandled.  I think we are recommending that as a convension.
>
> Thanks for your reviewing!
>
> I've attached a patch that reflects your comments.

Thanks for the patch! Here are the comments.

+ Number of times generic plan was choosen
+ Number of times custom plan was choosen

Typo: "choosen" should be "chosen"?

+ <entry role="catalog_table_entry"><para role="column_definition">
+ <structfield>last_plan_type</structfield> <type>text</type>
+ </para>
+ <para>
+ Tells the last plan type was generic or custom. If the prepared
+ statement has not executed yet, this field is null
+ </para></entry>

Could you tell me how this information is expected to be used?
I think that generic_plans and custom_plans are useful when investigating
the cause of performance drop by cached plan mode. But I failed to get
how much useful last_plan_type is.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Cramer 2020-07-06 13:35:36 Re: Binary support for pgoutput plugin
Previous Message Daniel Gustafsson 2020-07-06 13:03:32 Re: Binary support for pgoutput plugin