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

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Christoph Berg <myon(at)debian(dot)org>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Lukas Fittl <lukas(at)fittl(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-03-25 16:58:21
Message-ID: CAA5RZ0sy8gZzK0qNScY-C_jOpqQb6Y3EQaXHu0Ti9pon-4jJBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

> > Attached is the second one, with more tests coverage with attribute
> > aliases (these being ignored exists in stable branches, but why not
> > while on it) and table aliases, and the fixes for the issues pointed
> > out by Christoph. I'll double-check all that again tomorrow. Please
> > find an updated version attached for now.

There are several parts of the doc that may no longer hold true.

1/
"Since the queryid hash value is computed on the post-parse-analysis
representation of the queries, the opposite is also possible: queries with
identical texts might appear as separate entries, if they have different
meanings as a result of factors such as different search_path settings."

I think this text could remain as is, because search_path still
matters for things like functions, etc.

"""
postgres=# SET SEARCH_PATH=a;
SET
postgres=# explain verbose select * from test();
QUERY PLAN
------------------------------------------
Result (cost=0.00..0.01 rows=1 width=4)
Output: 1
Query Identifier: -1813735303617154554
(3 rows)

postgres=# SET SEARCH_PATH=b;
SET
postgres=# explain verbose select * from test();
QUERY PLAN
------------------------------------------
Result (cost=0.00..0.01 rows=1 width=4)
Output: 1
Query Identifier: -3896107319863686763
(3 rows)
"""

2/
"For example, pg_stat_statements will consider two apparently-identical
queries to be distinct, if they reference a table that was dropped and
recreated between the executions of the two queries."

This is no longer true for relations, but is still true for functions. I think
we should mention the caveats in a bit more detail as this change
will have impact on the most common case. What about something
like this?

"For example, pg_stat_statements will consider two apparently-identical
queries to be distinct, if they reference a function that was dropped and
recreated between the executions of the two queries. Conversely, if a table is
dropped and recreated between the executions of queries, two
apparently-identical
queries will be considered the same. However, if the alias for a table is
different for semantically similar queries, these queries will be
considered distinct"

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2025-03-25 17:07:12 Re: Replication slot WAL reservation
Previous Message Phillip Diffley 2025-03-25 16:56:39 Replication slot WAL reservation

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2025-03-25 17:27:57 Re: Squash constant lists in query jumbling by default
Previous Message Tom Lane 2025-03-25 16:53:13 Re: Squash constant lists in query jumbling by default