query column in pg_stat_statements and pg_stat_activity - Mailing list pgsql-performance

From Satalabaha Postgres
Subject query column in pg_stat_statements and pg_stat_activity
Date
Msg-id CAJ_W8nZYp95YqiAmyHGutv6sxPFnHxdtpurNLg6HuGg=Wo4=Ug@mail.gmail.com
Whole thread Raw
List pgsql-performance
I've written the below SQL query that joins pg_stat_statements with pg_stat_activity using "queryid" as the join condition. Yet, the results show that pg_stat_statements and pg_stat_activity are reporting two distinct queries for the identical queryid. Can this occur?

select

pgss.queryid as "PGSS_QUERYID",

pgss.query as "PGSS_QUERY",

pgsa.query_id as "PGSA_QUERYID",

substring(pgsa.query,

1,

45) as "PGSA_QUERY"

from

pg_stat_statements pgss

join pg_stat_activity pgsa on

pgss.queryid = pgsa.query_id

and pgss.queryid = '2397681704071010949';


    PGSS_QUERYID     | PGSS_QUERY |    PGSA_QUERYID     |                  PGSA_QUERY
---------------------+------------+---------------------+-----------------------------------------------
 2397681704071010949 | BEGIN      | 2397681704071010949 | select projectper0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select projectper0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 |  SELECT item_guid, count(item_guid) count  FR
 2397681704071010949 | BEGIN      | 2397681704071010949 |  SELECT item_guid, count(item_guid) count  FR
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | SELECT distinct ep.role FROM v_project_permis
 2397681704071010949 | BEGIN      | 2397681704071010949 | SELECT distinct ep.role FROM v_project_permis
 2397681704071010949 | BEGIN      | 2397681704071010949 | select this_.CONTACT_SID as CONTACT1_362_1_,
 2397681704071010949 | BEGIN      | 2397681704071010949 | select this_.CONTACT_SID as CONTACT1_362_1_,
 2397681704071010949 | BEGIN      | 2397681704071010949 |  SELECT item_guid,category,root_guid, count(i
 2397681704071010949 | BEGIN      | 2397681704071010949 |  SELECT item_guid,category,root_guid, count(i
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as
 2397681704071010949 | BEGIN      | 2397681704071010949 | select folderperm0_.ENTITY_PERMISSION_SID as

Regards,

Satalabha

pgsql-performance by date:

Previous
From: Chema
Date:
Subject: Re: Plan selection based on worst case scenario
Next
From: Vitaliy Litovskiy
Date:
Subject: Distinct performance dropped by multiple times in v16