pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Show savepoint names as constants in pg_stat_statements
Date: Thu, 27 Jul 2023 00:46:38 +0000
Message-ID: <E1qOp9J-001Vq6-QK@gemulon.postgresql.org> (raw)

Show savepoint names as constants in pg_stat_statements

In pg_stat_statements, savepoint names now show up as constants with a
parameter symbol, using as base query string the one added as a new
entry to the PGSS hash table, leading to:
RELEASE $1
ROLLBACK TO $1
SAVEPOINT $1

Applying constants to these query parts is a huge advantage for
workloads that generate randomly savepoint points, like ORMs (Django is
at the origin of this patch).  The ODBC driver is a second layer that
likes a lot savepoints, though it does not use a random naming pattern.

A "location" field is added to TransactionStmt, now set only for
savepoints.  The savepoint name is ignored by the query jumbling.  The
location can be extended to other query patterns, if required, like 2PC
commands.  Some tests are added to pg_stat_statements for all the query
patterns supported by the parser.

ROLLBACK, ROLLBACK TO SAVEPOINT and ROLLBACK TRANSACTION TO SAVEPOINT
have the same Node representation, so all these are equivalents.  The
same happens for RELEASE and RELEASE SAVEPOINT.

Author: Greg Sabino Mullane
Discussion: https://postgr.es/m/CAKAnmm+2s9PA4OaumwMJReWHk8qvJ_-g1WqxDRDAN1BSUfxyTw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/31de7e60da34761365f94dc76cc2c1bf2172d1bc

Modified Files
--------------
contrib/pg_stat_statements/expected/utility.out | 31 +++++++++++++++++++++++++
contrib/pg_stat_statements/sql/utility.sql      | 17 ++++++++++++++
src/backend/parser/gram.y                       | 14 +++++++++++
src/include/nodes/parsenodes.h                  |  5 +++-
4 files changed, 66 insertions(+), 1 deletion(-)



Message-ID: <E1qOp9J-001Vq6-QK@gemulon.postgresql.org>
Permalink:  ../E1qOp9J-001Vq6-QK@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qOp9J-001Vq6-QK@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Show savepoint names as constants in pg_stat_statements
  In-Reply-To: <E1qOp9J-001Vq6-QK@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