pgsql: Track identical top vs nested queries independently in pg_stat_s - Mailing list pgsql-committers

From Magnus Hagander
Subject pgsql: Track identical top vs nested queries independently in pg_stat_s
Date
Msg-id E1lUQ3v-0006sP-Io@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: pgsql: Move pg_stat_statements query jumbling to core.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: doc: Prefer explicit JOIN syntax over old implicit syntax in tut