Re: empty,query_id, pg_stat_activity

Greg Sabino Mullane <htamfids@gmail.com>

From: Greg Sabino Mullane <htamfids@gmail.com>
To: zhouenbing <zhouenbing@sunwoda-evb.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2025-09-03T20:54:27Z
Lists: pgsql-bugs
On Tue, Sep 2, 2025 at 10:01 PM zhouenbing <zhouenbing@sunwoda-evb.com>
wrote:

> No, if the query_id I provided is empty, it indicates that the statement
> session is in an active state, meaning the operation is ongoing
>

The session is active, but there is no I/O yet, as the query has arrived,
but has not been parsed yet. The queryid appears right before the query
actually executes, so a lack of queryid is a safe indicator that the query
is not actually doing any work yet- it's still spinning up. From a
performance monitoring standpoint, you should be safe to exclude rows with
no queryid.

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support