答复: empty,query_id, pg_stat_activity

From: "zhouenbing" <zhouenbing(at)sunwoda-evb(dot)com>
To: "'Michael Paquier'" <michael(at)paquier(dot)xyz>, "'Greg Sabino Mullane'" <htamfids(at)gmail(dot)com>
Cc: <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: 答复: empty,query_id, pg_stat_activity
Date: 2025-09-04 03:32:18
Message-ID: 000b01dc1d4c$865eec00$931cc400$@sunwoda-evb.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

hello Michael
The application scenario for performing performance analysis on
Postgres through query_id is as follows:
First, monitor the events and query_ids of the active database sessions
during the current or past period by using the pg_stat_activity or
pg_active_session_history views to analyze performance issues. Then, quickly
locate the detailed execution information of the SQL statements by using the
query_id of the session SQL in the pg_stat_statements.
Aggregate and statistically analyze the performance of the SQL at different
time points in the past by aggregating in pg_stat_statements_history within
the specified time period.
However, at present, some active sessions in pg_stat_activity have empty
query_ids, which leads to many query_ids being empty in
pg_active_session_history as well. If Mr. Greg said that empty query_ids
indicate that the session SQL has not been executed, then I will exclude the
sessions with empty query_ids. But I think that if the SQL has not been
executed, the session status should be 'inactive' instead.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Raghvendra Mishra 2025-09-04 08:59:44 Postgres immediately closing connection when `systemctl reboot` command is fired.
Previous Message Michael Paquier 2025-09-04 00:25:00 Re: empty,query_id, pg_stat_activity