Re: compute_query_id and pg_stat_statements
Julien Rouhaud <rjuju123@gmail.com>
From: Julien Rouhaud <rjuju123@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Stephen Frost <sfrost@snowman.net>, Magnus Hagander <magnus@hagander.net>, Bruce Momjian <bruce@momjian.us>, Christoph Berg <myon@debian.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Fujii Masao <masao.fujii@oss.nttdata.com>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2021-05-11T07:35:39Z
Lists: pgsql-hackers
Attachments
- v1-0001-Change-compute_query_id-to-an-enum-GUC.patch (text/x-diff)
On Tue, May 11, 2021 at 03:04:13PM +0900, Michael Paquier wrote: > On Tue, Apr 27, 2021 at 02:25:04PM +0800, Julien Rouhaud wrote: > > On Mon, Apr 26, 2021 at 11:37:45AM -0700, Andres Freund wrote: > >> On 2021-04-26 14:21:00 -0400, Tom Lane wrote: > >>> That's sounding like a pretty sane design, actually. Not sure about > >>> the shared-library-name-with-fixed-function-name detail, but certainly > >>> it seems to be useful to separate "I need a query-id" from the details > >>> of the ID calculation. > >>> > >>> Rather than a GUC per se for the ID provider, maybe we could have a > >>> function hook that defaults to pointing at the in-core computation, > >>> and then a module wanting to override that just gets into the hook. > >> > >> I have a preference to determining the provider via GUC instead of a > >> hook because it is both easier to introspect and easier to configure. > > So, this thread has died two weeks ago, and it is still an open item. > Could it be possible to move to a resolution by beta1? The consensus > I can get from the thread is that we should have a tri-value state to > track an extra "auto" for the query ID computation, as proposed by > Alvaro here: > https://www.postgresql.org/message-id/20210426174331.GA19401@alvherre.pgsql > > Unfortunately, nothing has happened to be able to do something like > that. My understanding was that there wasn't a consensus on how to fix the problem. Anyway, PFA a patch that implement a [off | on | auto] compute_query_id, and provides a new queryIdWanted() function to let third party plugins inform us that they want a query id if possible. As it was noted somewhere in that thread, that's a hack on top on the GUC machinery, so compute_query_id will display "on" rather than "auto" (or "auto and enabled" or whatever) since GUC isn't designed to handle that behavior. For the record I also tested the patch using pg_qualstats(), which can be loaded interactively and also benefits from a query identifier. It works as expected, as in "query idenfitier are enabled but only for the backend that loaded pg_qualstats".
Commits
-
Allow compute_query_id to be set to 'auto' and make it default
- cafde58b337e 14.0 landed
-
Move pg_stat_statements query jumbling to core.
- 5fd9dfa5f50e 14.0 cited