Re: Proposal - Allow extensions to set a Plan Identifier

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Lukas Fittl <lukas(at)fittl(dot)com>
Subject: Re: Proposal - Allow extensions to set a Plan Identifier
Date: 2025-02-14 07:21:48
Message-ID: Z67vDDVl0nv4Hgmk@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 13, 2025 at 11:10:27AM -0600, Sami Imseih wrote:
> I don't think direct setting of values is a good idea. We will need an API
> similar to pgstat_report_query_id which ensures we are only reporting top
> level planIds -and- in the case of multiple extensions with the capability
> to set a planId, only the first one in the stack wins. pgstat_report_query_id
> does allow for forcing a queryId ( force flag which is false by default ), and
> I think this new API should allow the same.

Yep. The main idea behind that is to offer to extensions one single
and consistent way to set this kind of data. In short, we have use
cases where we want to be able to associate an ID with a plan tree,
we're not sure which algorithm would be the best one to use in core.

One thing that we are sure about is that there is no easy way to
figure out through the planner hook across multiple extensions if this
has been set with an in-core structure. Sure, you can do that with a
shmem area associated to one of the extensions, but it seems just
easier to plug in a set/get logic into core, including a way to force
setting the ID?

The key point to me is to add that to the backend entry structure and
a plan node structure, so as it is possible to track that through the
planner hook for the planner structure. The backend entry is for
monitoring, not really pg_stat_activity first.

I'm obviously siding with this proposal because we have an ask to
track this kind of data, and because this kind of data is kind of hard
to track across a stack of extensions through the core backend code.

Point is, would others be interested in this addition or just object
to it because it touches the core code?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shlok Kyal 2025-02-14 07:29:05 Re: Restrict publishing of partitioned table with a foreign table as partition
Previous Message Amit Kapila 2025-02-14 07:18:42 Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding