pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Magnus Hagander <magnus@hagander.net>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Track identical top vs nested queries independently in pg_stat_s
Date: Thu, 08 Apr 2021 08:30:51 +0000
Message-ID: <E1lUQ3v-0006sP-Io@gemulon.postgresql.org> (raw)

Track identical top vs nested queries independently in pg_stat_statements

Changing pg_stat_statements.track between 'all' and 'top' would control
if pg_stat_statements tracked just top level statements or also
statements inside functions, but when tracking all it would not
differentiate between the two. Being table to differentiate this is
useful both to track where the actual query is coming from, and to see
if there are differences in executions between the two.

To do this, add a boolean to the hash key indicating if the statement
was top level or not.

Experience from the pg_stat_kcache module shows that in at least some
"reasonable worloads" only <5% of the queries show up both top level and
nested. Based on this, admittedly small, dataset, this patch does not
try to de-duplicate those query *texts*, and will just store one copy
for the top level and one for the nested.

Author: Julien Rohaud
Reviewed-By: Magnus Hagander, Masahiro Ikeda
Discussion: https://postgr.es/m/20201202040516.GA43757@nol

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6b4d23feef6e334fb85af077f2857f62ab781848

Modified Files
--------------
contrib/pg_stat_statements/Makefile                |  3 +-
.../expected/pg_stat_statements.out                | 40 +++++++++++++++
.../pg_stat_statements--1.9--1.10.sql              | 57 ++++++++++++++++++++++
contrib/pg_stat_statements/pg_stat_statements.c    | 50 ++++++++++++++++---
.../pg_stat_statements/pg_stat_statements.control  |  2 +-
.../pg_stat_statements/sql/pg_stat_statements.sql  | 21 ++++++++
doc/src/sgml/pgstatstatements.sgml                 |  9 ++++
7 files changed, 173 insertions(+), 9 deletions(-)



Message-ID: <E1lUQ3v-0006sP-Io@gemulon.postgresql.org>
Permalink:  ../E1lUQ3v-0006sP-Io@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lUQ3v-0006sP-Io@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: magnus@hagander.net
  Subject: Re: pgsql: Track identical top vs nested queries independently in pg_stat_s
  In-Reply-To: <E1lUQ3v-0006sP-Io@gemulon.postgresql.org>
  References: <E1lUQ3v-0006sP-Io@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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