Re: query_id: jumble names of temp tables for better pg_stat_statement UX

From: Alexander Kukushkin <cyberdemn(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christoph Berg <myon(at)debian(dot)org>, Lukas Fittl <lukas(at)fittl(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, ma lz <ma100(at)hotmail(dot)com>
Subject: Re: query_id: jumble names of temp tables for better pg_stat_statement UX
Date: 2025-07-16 06:20:39
Message-ID: CAFh8B=m5BPeo7vTYDSw2KV=CmjeATWGw-CHCZmJ+3ZKm7kVM1w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Wed, 16 Jul 2025 at 01:39, Michael Paquier <michael(at)paquier(dot)xyz> wrote:

>
> > create schema s1;
> > create table s1.t as select id from generate_series(1, 10) as id;
> > create schema s2;
> > create table s1.t as select id from generate_series(1, 1000000) as id;
>
> I suspect that you mean s2.t and not s1.t here.
>

Yes.

> Yes, we had this argument upthread, and it is still possible to
> differentiate both cases by using a different alias in the FROM
> clause, as of:
> select count(id) from s1.t as t1;
> select count(id) from s2.t as t2;
>
> The new behavior where we do not need to worry about temporary tables,
> which is not that uncommon because some workloads like using these for
> JOIN patterns as a "temporary" anchor in a session, has more benefits
> IMO, particularly more if the connections have a rather higher
> turnover.

Yes, I've seen this argument and know that aliases will make these queries
look different.
However, we regularly hear from many different customers that they *don't
control queries* sent by application or *can't modify these queries*.
Such kinds of workloads are also not that uncommon and this change makes it
impossible to monitor them.

I would somewhat understand when a table in the query is used without
specifying schema and such queries are merged together:
s1: SET search_path s1; select count(*) from t;
s2: SET search_path s2; select count(*) from t;

But, even this case doesn't feel right, because these tables are still
different and therefore queries.

Regards,
--
Alexander Kukushkin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message KK CHN 2025-07-16 07:22:54 PgBouncer-Postgres : un supported startup parameter statement_timeout
Previous Message Kiran K V 2025-07-16 00:53:49 Re: Query regarding support of test_decoding and PGReplicationStream with Standby Logical Replication

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2025-07-16 06:29:21 Re: Collation and primary keys
Previous Message Michael Paquier 2025-07-16 06:01:38 Re: track generic and custom plans in pg_stat_statements