Re: track generic and custom plans in pg_stat_statements

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Nikolay Samokhvalov <nik(at)postgres(dot)ai>
Subject: Re: track generic and custom plans in pg_stat_statements
Date: 2025-07-16 23:46:35
Message-ID: CAA5RZ0vdKkmkaS6EkFNgzM+FDbS84c4hH6JTnHpWVBTPVz6O6g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > Ugh. This is plugging into an executor-related structure a completely
> > different layer, so that looks like an invasive layer violation to
> > me.. This is passed through ProcessQuery() from a Portal, changing
> > while on it ExplainOnePlan. If we want to get access from a cached
> > plan, wouldn't it be simpler to check if we have an active portal in
> > one of the executor hooks of PGSS and retrieve the status of the plan
> > from it? Okay, that's perhaps a bit hack-ish, but it is less invasive
> > and it removes the dependency to the plan cache facilities from
> > QueryDesc.
>
> I found that ActivePortal is to always "active" in ExecutorEnd for all
> cases.
> Also, ActivePortal->cplan may not always be available at ExecutorStart.
>
> I think we can rely on ActivePortal if we add a new field to portal which
> tracks the cached plan status; i.e. we set ActivePortal->cache_plan_status
> inside GetCachedPlan. Then in ExecutorStart, we read back this value and
> store it in a new field in QueryDesc->estate. This will make the value
> available to ExecutorEnd. I really don't want us making an extra pgss_store
> call in ExecutorStart since it will add significant overhead.
>
> What do you think about adding these couple of fields?
>
> --
> Sami

But I also have doubts about calling ActivePortal
Inside GetCachedPlan. It should only be used in the Executor
So, I’m not sure ActivePortal could
be very helpful here they way I describe it above.

--
Sami

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-07-17 00:08:15 Re: Improve error reporting in 027_stream_regress test
Previous Message jian he 2025-07-16 23:38:54 duplicate line in ExecEvalJsonCoercionFinish