pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Improve contrib/pg_stat_statements' handling of PREPARE/EXECUTE
Date: Thu, 29 Mar 2012 20:42:34 +0000
Message-ID: <E1SDMB0-0002vV-FY@gemulon.postgresql.org> (raw)

Improve contrib/pg_stat_statements' handling of PREPARE/EXECUTE statements.

It's actually more useful for the module to ignore these.  Ignoring
EXECUTE (and not incrementing the nesting level) allows the executor
hooks to charge the time to the underlying prepared query, which
shows up as a stats entry with the original PREPARE as query string
(possibly modified by suppression of constants, which might not be
terribly useful here but it's not worth avoiding).  This is much more
useful than cluttering the stats table with a distinct entry for each
textually distinct EXECUTE.

Experimentation with this idea shows that it's also preferable to ignore
PREPARE.  If we don't, we get two stats table entries, one with the query
string hash and one with the jumble-derived hash, but with the same visible
query string (modulo those constants).  This is confusing and not very
helpful, since the first entry will only receive costs associated with
initial planning of the query, which is not something counted at all
normally by pg_stat_statements.  (And if we do start tracking planning
costs, we'd want them blamed on the other hash table entry anyway.)

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/566a1d43cf6bfcc7f9385b581d98e07eab282cdd

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c |   19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1SDMB0-0002vV-FY@gemulon.postgresql.org>
Permalink:  ../E1SDMB0-0002vV-FY@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1SDMB0-0002vV-FY@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Improve contrib/pg_stat_statements' handling of PREPARE/EXECUTE
  In-Reply-To: <E1SDMB0-0002vV-FY@gemulon.postgresql.org>
  References: <E1SDMB0-0002vV-FY@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