public inbox for [email protected]  
help / color / mirror / Atom feed
Re: pg_stat_statements has duplicate entries for the same query & queryId
2+ messages / 2 participants
[nested] [flat]

* Re: pg_stat_statements has duplicate entries for the same query & queryId
@ 2025-05-19 07:07  Daniel Verite <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Daniel Verite @ 2025-05-19 07:07 UTC (permalink / raw)
  To: Jevon Cowell <[email protected]>; +Cc: [email protected]

	Jevon Cowell wrote:

> What I'm seeing is that for the same query *and* query id,
> there are two rows with different statistics data *at the same time*. For
> example one row can have 2 calls while another can have 4

That looks normal. The unicity to expect is on 
(queryid, userid, dbid, toplevel).

From https://www.postgresql.org/docs/current/pgstatstatements.html :

  This view contains one row for each distinct combination of database
  ID, user ID, query ID and whether it's a top-level statement or not
  (up to the maximum number of distinct statements that the module can
  track)


Best regards,
-- 
Daniel Vérité 
https://postgresql.verite.pro/






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pg_stat_statements has duplicate entries for the same query & queryId
@ 2025-05-19 21:51  Michael Paquier <[email protected]>
  parent: Daniel Verite <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2025-05-19 21:51 UTC (permalink / raw)
  To: Daniel Verite <[email protected]>; +Cc: Jevon Cowell <[email protected]>; [email protected]

On Mon, May 19, 2025 at 09:07:35AM +0200, Daniel Verite wrote:
> That looks normal. The unicity to expect is on 
> (queryid, userid, dbid, toplevel).
> 
> From https://www.postgresql.org/docs/current/pgstatstatements.html :
> 
>   This view contains one row for each distinct combination of database
>   ID, user ID, query ID and whether it's a top-level statement or not
>   (up to the maximum number of distinct statements that the module can
>   track)

Yeah.  The uniqueness of the entries in the PGSS hash table is
enforced by pgssHashKey in pg_stat_statements.c.  Or an unknown bug
has been found, but there is no data proving that here.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, 2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-05-19 21:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-05-19 07:07 Re: pg_stat_statements has duplicate entries for the same query & queryId Daniel Verite <[email protected]>
2025-05-19 21:51 ` Michael Paquier <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox