Re: [doc] plan invalidation when statistics are update

From: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [doc] plan invalidation when statistics are update
Date: 2020-11-19 05:33:54
Message-ID: 4b67637403d487a242e89b279baf56ae@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-11-18 11:35, Fujii Masao wrote:

Thanks for your comment!

> On 2020/11/18 11:04, torikoshia wrote:
>> Hi,
>>
>> AFAIU, when the planner statistics are updated, generic plans are
>> invalidated and PostgreSQL recreates. However, the manual doesn't seem
>> to explain it explicitly.
>>
>>   https://www.postgresql.org/docs/devel/sql-prepare.html
>>
>> I guess this case is included in 'whenever database objects used in
>> the statement have definitional (DDL) changes undergone', but I feel
>> it's hard to infer.
>>
>> Since updates of the statistics can often happen, how about describing
>> this case explicitly like an attached patch?
>
> +1 to add that note.
>
> - statement. Also, if the value of <xref linkend="guc-search-path"/>
> changes
> + statement. For example, when the planner statistics of the
> statement
> + are updated, <productname>PostgreSQL</productname> re-analyzes and
> + re-plans the statement.
>
> I don't think "For example," is necessary.
>
> "planner statistics of the statement" sounds vague? Does the statement
> is re-analyzed and re-planned only when the planner statistics of
> database
> objects used in the statement are updated? If yes, we should describe
> that to make the note a bit more explicitly?

Yes. As far as I confirmed, updating statistics which are not used in
prepared statements doesn't trigger re-analyze and re-plan.

Since plan invalidations for DDL changes and statistcal changes are
caused
by PlanCacheRelCallback(Oid 'relid'), only the prepared statements using
'relid' relation seem invalidated.

Attached updated patch.

Regards,

-
Atsushi Torikoshi

Attachment Content-Type Size
v2-0001-add-an-example-of-replanning-generic-plan.patch text/x-diff 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-11-19 05:42:02 Re: Protect syscache from bloating with negative cache entries
Previous Message Greg Stark 2020-11-19 05:28:27 Re: Is postgres ready for 2038?