Re: compute_query_id and pg_stat_statements

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>, Christoph Berg <myon(at)debian(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: compute_query_id and pg_stat_statements
Date: 2021-05-13 01:13:25
Message-ID: 20210513011325.GA11075@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 13, 2021 at 08:52:36AM +0800, Julien Rouhaud wrote:
> On Wed, May 12, 2021 at 08:36:18PM -0400, Bruce Momjian wrote:
> > The problem with compute_query_id=auto is that there is no way to know
> > if the query id is actually enabled, unless you guess from the installed
> > extensions, or we add another variable to report that, and maybe another
> > variable to control the provier, unless we require turning
> > compute_query_id=off if you are using custom query id computation. What
> > if it is auto, and pg_stat_statments is installed, and you want to use a
> > custom query id computation --- what happens? As you can see, this is
> > all becoming very complicated.
>
> Well, as implemented you can get the value of compute_query_id, and if it's
> still "auto" then it's not enabled as calling queryIdWanted() would turn it to
> on. I agree that it's not ideal but you have a way to know. We could document
> that auto means that it's set to auto and no one asked to automatically enabled
> it.

Wow, so the extension changes it? How do we record the "source" of that
change? Do we have other GUCs that do that?

> Or you can just do e.g.
>
> SELECT query_id FROM pg_stat_activity WHERE pid = pg_backend_pid();
>
> and see if you have a query_id or not.

True.

> If you want to use third-party modules, they you have to explicitly disable
> compute_query_id. If you don't, every query execution will raise an error as
> we documented that third-party modules should error out if they see that a
> query_id is already generated. Such module could also explicitly check that
> compute_query_id is off and also raise an error if that's not the case.

OK.

> > I think we might be just as well to go with compute_query_id=on/off, and
> > just complain loudly from CREATE EXTENSION, or in the server logs on
> > server start via shared_preload_libraries, or when querying
> > pg_stat_statements system view. We simply say to change
> > compute_query_id=on or to provide a custom query id implementation.
>
> I'm not opposed to that, but it was already suggested and apparently people
> didn't like that approach.

Also probably true.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pengchengliu 2021-05-13 01:25:05 RE: Parallel scan with SubTransGetTopmostTransaction assert coredump
Previous Message Kyotaro Horiguchi 2021-05-13 01:12:37 Re: compute_query_id and pg_stat_statements