From 4f0b0966c866ae9f0e15d7cc73ccf7ce4e1af84b Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 7 Apr 2021 14:03:56 -0400 Subject: Make use of in-core query id added by commit 5fd9dfa5f5 Use the in-core query id computation for pg_stat_activity, log_line_prefix, and EXPLAIN VERBOSE. Similar to other fields in pg_stat_activity, only the queryid from the top level statements are exposed, and if the backends status isn't active then the queryid from the last executed statements is displayed. Add a %Q placeholder to include the queryid in log_line_prefix, which will also only expose top level statements. For EXPLAIN VERBOSE, if a query identifier has been computed, either by enabling compute_query_id or using a third-party module, display it. Bump catalog version. Discussion: https://postgr.es/m/20210407125726.tkvjdbw76hxnpwfi@nol Author: Julien Rouhaud Reviewed-by: Alvaro Herrera, Nitin Jadhav, Zhihong Yu --- doc/src/sgml/config.sgml | 29 +++++++++++++++++++++-------- doc/src/sgml/monitoring.sgml | 16 ++++++++++++++++ doc/src/sgml/ref/explain.sgml | 6 ++++-- 3 files changed, 41 insertions(+), 10 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 9d846cb7be0..18447f404ce 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -7004,6 +7004,15 @@ local0.* /var/log/postgresql session processes no + + %Q + query identifier of the current query. Query + identifiers are not computed by default, so this field + will be zero unless + parameter is enabled or a third-party module that computes + query identifiers is configured. + yes + %% Literal % @@ -7480,8 +7489,8 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; Enables the collection of information on the currently - executing command of each session, along with the time when - that command began execution. This parameter is on by + executing command of each session, along with its identifier and the + time when that command began execution. This parameter is on by default. Note that even when enabled, this information is not visible to all users, only to superusers and the user owning the session being reported on, so it should not represent a @@ -7630,12 +7639,16 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; - Enables in-core computation of a query identifier. The extension requires a query identifier - to be computed. Note that an external module can alternatively - be used if the in-core query identifier computation method - isn't acceptable. In this case, in-core computation should - remain disabled. The default is off. + Enables in-core computation of a query identifier. + Query identifiers can be displayed in the pg_stat_activity + view, using EXPLAIN, or emitted in the log if + configured via the parameter. + The extension also requires a query + identifier to be computed. Note that an external module can + alternatively be used if the in-core query identifier computation + specification isn't acceptable. In this case, in-core computation + must be disabled. The default is off. diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 56018745c89..52958b4fd91 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -910,6 +910,22 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser + + + queryid bigint + + + Identifier of this backend's most recent query. If + state is active this + field shows the identifier of the currently executing query. In + all other states, it shows the identifier of last query that was + executed. Query identifiers are not computed by default so this + field will be null unless + parameter is enabled or a third-party module that computes query + identifiers is configured. + + + query text diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index c4512332a06..4d758fb237e 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -136,8 +136,10 @@ ROLLBACK; the output column list for each node in the plan tree, schema-qualify table and function names, always label variables in expressions with their range table alias, and always print the name of each trigger for - which statistics are displayed. This parameter defaults to - FALSE. + which statistics are displayed. The query identifier will also be + displayed if one has been computed, see for more details. This parameter + defaults to FALSE. -- cgit v1.2.3