Re: compute_query_id and pg_stat_statements

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: 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>, Bruce Momjian <bruce(at)momjian(dot)us>, 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-12 07:51:26
Message-ID: CAFj8pRCWjQtw6A8t335P0soehc0ypjCz38aoASRbP7diWmQmtg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

st 12. 5. 2021 v 9:13 odesílatel Julien Rouhaud <rjuju123(at)gmail(dot)com> napsal:

> On Wed, May 12, 2021 at 08:58:45AM +0200, Pavel Stehule wrote:
> >
> > I don't like the idea of implicit force enabling any feature flag, but it
> > is better than current design. But it doesn't look like a robust
> solution.
> >
> > Does it mean that if somebody disables computed_query_id, then
> > pg_stat_statements will not work?
>
> It depends, but if you mean "setting up pg_stat_statements, intentionally
> disabling in-core queryid calculation and not configuring an alternative
> source" then yes pg_stat_statements will not work. But I don't see any
> difference from "someone reduce wal_level and complain that replication
> does
> not work" or "someone disable fsync and complain that data got
> corrupted". We
> provide a sensible default configuration, you can mess it up if you don't
> know
> what you're doing.
>

> > Why is there the strong dependency between computed_query_id and
> > pg_stat_statements? Can this dependency be just optional?
>
> Once again no, as it otherwise would mean that postgres unilaterally
> decides
> that pg_stat_statements' approach to compute a query identifier is the one
> and
> only ultimate truth and nothing else could be useful for anyone.
>

ok. Understand.

If I understand well, then computed_query_id does not make sense for
pg_stat_statemenst, because this extension always requires it.

Cannot be better to use queryid inside pg_stat_statements every time
without dependency on computed_query_id? And computed_query_id can be used
only for EXPLAIN and for pg_stat_activity.

pg_stat_statements cannot work without a queryid, so is useless to speak
about configuration. If you use pg_stat_statements, then the queryid will
be computed every time, but the visibility will be only for
pg_stat_statements.

Or a different strategy. I understand so computed_query_id should be
active. But I dislike the empty result of pg_stat_statements when
computed_query_id is off. Is it possible to raise an exception instead of
showing an empty result?

The most correct fix from my perspective is just check in function
pg_stat_statements if query id is computed or not. If not, and there is no
data, then raise an exception with the hint "enable compute_query_id". When
there is data, then show a warning with the mentioned hint and show data.

What do you think about it?

Pavel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-05-12 07:52:42 Re: GetSubscriptionRelations declares too many scan keys
Previous Message yuzuko 2021-05-12 07:48:29 Re: Feedback on table expansion hook (including patch)