Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?
Julien Rouhaud <rjuju123@gmail.com>
From: Julien Rouhaud <rjuju123@gmail.com>
To: Bruce Momjian <bruce@momjian.us>
Cc: Michael Paquier <michael@paquier.xyz>,
Alvaro Herrera <alvherre@alvh.no-ip.org>, Tom Lane <tgl@sss.pgh.pa.us>, torikoshia <torikoshia@oss.nttdata.com>, Atsushi Torikoshi <atorik@gmail.com>,
Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>, Robert Haas <robertmhaas@gmail.com>,
Tomas Vondra <tomas.vondra@2ndquadrant.com>, Evgeny Efimkin <efimkin@yandex-team.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-10-12T08:20:05Z
Lists: pgsql-hackers
On Wed, Oct 7, 2020 at 9:53 AM Bruce Momjian <bruce@momjian.us> wrote: > > On Wed, Oct 7, 2020 at 10:42:49AM +0900, Michael Paquier wrote: > > On Tue, Oct 06, 2020 at 09:22:29AM -0400, Bruce Momjian wrote: > > > I propose moving the pg_stat_statements queryid hash code into the > > > server (with a version number), and also adding a postgresql.conf > > > variable that lets you control how detailed the queryid hash is > > > computed. This addresses the problem of people wanting different hash > > > methods. > > > > In terms of making this part expendable in the future, there could be > > a point in having an enum here, but are we sure that we will have a > > need for that in the future? What I get from this discussion is that > > we want a unique source of truth that users can consume, and that the > > only source of truth proposed is the PGSS hashing. We may change the > > way we compute the query ID in the future, for example if it gets > > expanded to some utility statements, etc. But that would be > > controlled by the version number in the hash, not the GUC itself. > > Oh, if that is true, then I agree let's just go with the version number. But there are many people that aren't happy with the current hashing approach. If we're going to move the computation in core, shouldn't we listen to their complaints and let them pay some probably quite high overhead to base the hash on name and/or fully qualified name rather than OID? For instance people using logical replication to upgrade to a newer version may want to easily compare query performance on the new version, or people with multi-tenant databases may want to ignore the schema name to keep a low number of different queryid. It would probably still be possible to have a custom queryid hashing by disabling the core one and computing a new one in a custom extension, but that seems a bit hackish. Jumping back on Tom's point that there are judgment calls on what is examined or not, after a quick look I see at least two possible problems of ignored clauses: - WITH TIES clause - OVERRIDING clause I personally think that they shouldn't be ignored, but I don't know if they were only forgotten or ignored on purpose.
Commits
-
Clarify description of pg_stat_statements columns
- b4deefc39b93 15.0 landed
- 3b57d5af7435 14.0 landed
-
Fix wording in description of pg_stat_statements.toplevel
- f9e6d00df029 14.0 landed
-
Mention that toplevel is part of pg_stat_statements key.
- 7531fcb1fcf5 14.0 landed
-
adjust query id feature to use pg_stat_activity.query_id
- 9660834dd8bf 14.0 landed
-
Update copyright for 2021
- ca3b37487be3 14.0 cited
-
Take the statistics collector out of the loop for monitoring backends'
- b13c9686d084 8.2.0 cited