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: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Bruce Momjian <bruce@momjian.us>, Hannu Krosing <hannuk@google.com>, Robert Haas <robertmhaas@gmail.com>, Pavel Stehule <pavel.stehule@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Michael Paquier <michael@paquier.xyz>, torikoshia <torikoshia@oss.nttdata.com>, Atsushi Torikoshi <atorik@gmail.com>, Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, Evgeny Efimkin <efimkin@yandex-team.ru>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-03-25T02:36:38Z
Lists: pgsql-hackers
On Wed, Mar 24, 2021 at 01:02:00PM -0300, Alvaro Herrera wrote: > On 2021-Mar-24, Julien Rouhaud wrote: > > > From e08c9d5fc86ba722844d97000798de868890aba3 Mon Sep 17 00:00:00 2001 > > From: Bruce Momjian <bruce@momjian.us> > > Date: Mon, 22 Mar 2021 17:43:23 -0400 > > Subject: [PATCH v20 2/3] Expose queryid in pg_stat_activity and > > > src/backend/executor/execMain.c | 9 ++ > > src/backend/executor/execParallel.c | 14 ++- > > src/backend/executor/nodeGather.c | 3 +- > > src/backend/executor/nodeGatherMerge.c | 4 +- > > Hmm... > > I find it odd that there's executor code that acquires the current query > ID from pgstat, after having been put there by planner or ExecutorStart > itself. Seems like a modularity violation. I wonder if it would make > more sense to have the value maybe in struct EState (or perhaps there's > a better place -- but I don't think they have a way to reach the > QueryDesc anyhow), put there by ExecutorStart, so that places such as > execParallel, nodeGather etc don't have to fetch it from pgstat but from > EState. The current queryid is already available in the Estate, as the underlying PlannedStmt contains it. The problem is that we want to display the top level queryid, not the current query one, and the top level queryid is held in pgstat.
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