Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1utOzN-006QD5-Ls for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Sep 2025 11:15:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1utOzL-003AoB-Sf for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Sep 2025 11:15:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1utNHi-002x50-HA for pgsql-bugs@lists.postgresql.org; Tue, 02 Sep 2025 09:26:38 +0000 Received: from zg8tmja2lje4os43os4xodqa.icoremail.net ([206.189.79.184]) by magus.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1utNHY-0009ON-2e for pgsql-bugs@lists.postgresql.org; Tue, 02 Sep 2025 09:26:37 +0000 Received: from sunwoda-evb.com (unknown [119.146.89.130]) by hzbj-forward-1.icoremail.net (Coremail) with SMTP id AQAAfwB3QGA+uLZo4sUEAA--.7457S2; Tue, 02 Sep 2025 17:26:23 +0800 (CST) Received: from sunwoda-evb.com (unknown [172.27.103.90]) by mtasvr (Coremail) with SMTP id _____wD3SMANuLZoAZUPAA--.24483S3; Tue, 02 Sep 2025 17:25:34 +0800 (CST) Received: from DL000951 (unknown [172.27.103.90]) by evbmailapp01 (Coremail) with SMTP id 2_EbrAB3IuIMuLZoqDNLAA--.10782S2; Tue, 02 Sep 2025 17:25:33 +0800 (CST) From: "zhouenbing" To: Subject: empty,query_id, pg_stat_activity Date: Tue, 2 Sep 2025 17:25:31 +0800 Message-ID: <000a01dc1beb$8837b910$98a72b30$@sunwoda-evb.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000B_01DC1C2E.965BE370" X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adwb64POUn5dlQXNQaaS7DAykTK8sw== Content-Language: zh-cn X-CM-TRANSID: 2_EbrAB3IuIMuLZoqDNLAA--.10782S2 X-CM-SenderInfo: 52kr3vxqel0ww6vx045rgdgv1yeou0bp/ Authentication-Results: hzbj-forward-1.icoremail.net; spf=softfail smt p.mail=zhouenbing@sunwoda-evb.com; X-Coremail-Antispam: 1UD129KBjvJXoW7Aw17Aw1kWFW5CFWfJw1xAFb_yoW8XrW5pr 4Skwn3CF1UtF15XrW0k3Z7X3sxJ34rJFs0yryUWryfAFnxuw48Jr17CrW8CrWxGrW5tr1r Z34jkrsrua98t37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBIb4IE77IF4wAFF20E14v26r1j6r4UM7CIcVAFz4kK6r1j6r18 M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr 0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v2 6rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62 kv0487Mc02F40Eb7x2x7xS6ryj6rWUMc02F40E57IF67AEF4xIwI1l5I8CrVAKz4kIr2xC 04v26r4j6ryUMc02F40E42I26xC2a48xMcIj6xIIjxv20xvE14v26Fy26r45twAv7VC2z2 80aVAFwI0_GcC_XcWlOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMx02cVAK zwCY02Avz4vE14v_GFWlc2IjII80xcxEwVAKI48JMxvI42IY6xIIjxv20xvE14v26r1j6r 1xMxvI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lcIIF0xvEx4A2jsIE14v26r1j6r4U MxvI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UMxAIw28IcxkI7VAKI48JMxCjnVCFn7xvrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r106r1rMI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jr0_JrylIxkGc2Ij64vIr41lIxAIcVCF04k26c xKx2IYs7xG6rW3Jr0E3sUvcSsGvfC2KfnxnUUI43ZEXa7IUeq0P3UUUUU== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_000B_01DC1C2E.965BE370 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, everyone When I was studying the current SQL performance issues in Postgres, I found that some queryids in pg_stat_activity were empty. My other DBA colleagues had sent emails to consult the community, and the community replied that this was not a bug. However, this empty queryid problem will affect our ability to effectively track the SQL performance issues of the current session. For example, some SQL statements are too long in text and take too long to execute. Without queryid, it is very difficult for me to accurately locate which SQL statement is being executed in the active session in pg_stat_statements? At the same time, it is also very difficult to continue to effectively track the relevant execution status of the current active session's SQL. Session 1: pgbentch -I -s 10 testdb pgbentch -T1200 testdb session 2: psql -t<

Hello, = everyone

  When I was studying the current SQL = performance issues in Postgres, I found that some queryids in = pg_stat_activity were empty. My other DBA colleagues had sent emails to = consult the community, and the community replied that this was not a = bug. However, this empty queryid problem will affect our ability to = effectively track the SQL performance issues of the current session. For = example, some SQL statements are too long in text and take too long to = execute. Without queryid, it is very difficult for me to accurately = locate which SQL statement is being executed in the active session in = pg_stat_statements? At the same time, it is also very difficult to = continue to effectively track the relevant execution status of the = current active session's SQL.

 

Session 1: pgbentch = –I –s 10 = testdb

          =     pgbentch -T1200  testdb

session 2: psql –t<<EOF

select = pid,query_id,state,query from pg_stat_activity where = pid=3D510506;

\watch = 0.2

EOF =

pid   = |       = query_id       | state  | query =

--------+----------------------+--------+-------<= /span>

510506 | 3130448535078843330 | active | INSERT INTO = pgbench_history (tid, bid, aid, delta, mtime) VALUES (65, 6, 910745, = -4761, CURRENT_TIMESTAMP);

510506 = |          | active | = UPDATE pgbench_accounts SET abalance =3D abalance + -2452 WHERE aid =3D = 516851;

510506 = |          | active | = SELECT abalance FROM pgbench_accounts WHERE aid =3D = 279298;

510506 | = 447485537170305879 | active | UPDATE pgbench_tellers SET tbalance =3D = tbalance + -3450 WHERE tid =3D = 73;

------=_NextPart_000_000B_01DC1C2E.965BE370--