diff options
author | Bruce Momjian <bruce@momjian.us> | 2021-04-07 14:03:56 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2021-04-07 14:04:06 -0400 |
commit | 4f0b0966c866ae9f0e15d7cc73ccf7ce4e1af84b (patch) | |
tree | f0848c536dcce037e64218f52bd9bc8f1cc3f0ae /doc/src | |
parent | ec7ffb8096e8eb90f4c9230f7ba9487f0abe1a9f (diff) | |
download | postgresql-4f0b0966c866ae9f0e15d7cc73ccf7ce4e1af84b.tar.gz postgresql-4f0b0966c866ae9f0e15d7cc73ccf7ce4e1af84b.zip |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 29 | ||||
-rw-r--r-- | doc/src/sgml/monitoring.sgml | 16 | ||||
-rw-r--r-- | doc/src/sgml/ref/explain.sgml | 6 |
3 files changed, 41 insertions, 10 deletions
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 @@ -7005,6 +7005,15 @@ local0.* /var/log/postgresql <entry>no</entry> </row> <row> + <entry><literal>%Q</literal></entry> + <entry>query identifier of the current query. Query + identifiers are not computed by default, so this field + will be zero unless <xref linkend="guc-compute-query-id"/> + parameter is enabled or a third-party module that computes + query identifiers is configured.</entry> + <entry>yes</entry> + </row> + <row> <entry><literal>%%</literal></entry> <entry>Literal <literal>%</literal></entry> <entry>no</entry> @@ -7480,8 +7489,8 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; <listitem> <para> 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; </term> <listitem> <para> - Enables in-core computation of a query identifier. The <xref - linkend="pgstatstatements"/> 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 <literal>off</literal>. + Enables in-core computation of a query identifier. + Query identifiers can be displayed in the <link + linkend="monitoring-pg-stat-activity-view"><structname>pg_stat_activity</structname></link> + view, using <command>EXPLAIN</command>, or emitted in the log if + configured via the <xref linkend="guc-log-line-prefix"/> parameter. + The <xref linkend="pgstatstatements"/> 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 <literal>off</literal>. </para> <note> <para> 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 </para></entry> </row> + <row> + <entry role="catalog_table_entry"><para role="column_definition"> + <structfield>queryid</structfield> <type>bigint</type> + </para> + <para> + Identifier of this backend's most recent query. If + <structfield>state</structfield> is <literal>active</literal> 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 <xref linkend="guc-compute-query-id"/> + parameter is enabled or a third-party module that computes query + identifiers is configured. + </para></entry> + </row> + <row> <entry role="catalog_table_entry"><para role="column_definition"> <structfield>query</structfield> <type>text</type> 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 - <literal>FALSE</literal>. + which statistics are displayed. The query identifier will also be + displayed if one has been computed, see <xref + linkend="guc-compute-query-id"/> for more details. This parameter + defaults to <literal>FALSE</literal>. </para> </listitem> </varlistentry> |