Re: compute_query_id and pg_stat_statements
Julien Rouhaud <rjuju123@gmail.com>
From: Julien Rouhaud <rjuju123@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Magnus Hagander <magnus@hagander.net>, Fujii Masao <masao.fujii@oss.nttdata.com>, Michael Paquier <michael@paquier.xyz>, Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Stephen Frost <sfrost@snowman.net>, Bruce Momjian <bruce@momjian.us>, Christoph Berg <myon@debian.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-05-12T09:51:49Z
Lists: pgsql-hackers
On Wed, May 12, 2021 at 11:42:12AM +0200, Pavel Stehule wrote: > st 12. 5. 2021 v 11:39 odesílatel Kyotaro Horiguchi <horikyota.ntt@gmail.com> > napsal: > > > At Wed, 12 May 2021 17:30:26 +0800, Julien Rouhaud <rjuju123@gmail.com> > > wrote in > > > On Wed, May 12, 2021 at 10:57:25AM +0200, Pavel Stehule wrote: > > > > > > > > My second proposal can work for your example too. pg_stat_statements > > have > > > > to require any active queryid computing. And when it is not available, > > then > > > > the exception should be raised. > > > > > > > > The custom queryid can return null, and still the queryid will be > > computed. > > > > Maybe the warning can be enough. Just, if somebody use > > pg_stat_statements > > > > function, then enforce the check if queryid is computed > > (compute_query_id > > > > is true || some hook is not null), and if not then raise a warning. > > > > > > Ah I'm sorry I misunderstood your proposal. Yes, definitely adding a > > warning > > > or an error when executing pg_stat_statements() SRF would help, that's a > > great > > > idea! > > > > > > I'll wait a bit in case someone has any objection, and if not send an > > updated > > > patch! > > > > Isn't there a case where pg_stat_statements uses an alternative > > query-id provider? > > > > this check just can check if there is "any" query-id provider. In this > context is not important if it is buildin or external Yes, the idea is that if you execute "SELECT * FROM pg_stat_statements" or similar, then if the executing query itself doesn't have a queryid then it's very likely that you didn't configure compute_query_id or an alternative query_id implementation properly. And loudly complaining seems like the right thing to do.
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