Skip site navigation (1) Skip section navigation (2)

Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Geoghegan <peter(at)2ndquadrant(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)
Date: 2012-03-29 20:08:04
Message-ID: CA+TgmobxLMg66eXcj5139=uJNCOLBbLNmbXEEWv7WGv89GHn9Q@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thu, Mar 29, 2012 at 4:05 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
>> ... PREPARE/EXECUTE work a bit funny though: if you have
>> track = all then you get EXECUTE cycles reported against both the
>> EXECUTE statement and the underlying PREPARE.  This is because when
>> PREPARE calls parse_analyze_varparams the post-analyze hook doesn't know
>> that this isn't a top-level statement, so it marks the query with a
>> queryId.  I don't see any way around that part without something like
>> what I suggested before.  However, this behavior seems to me to be
>> considerably less of a POLA violation than the cases involving two
>> identical-looking entries for self-contained statements, and it might
>> even be thought to be a feature not a bug (since the PREPARE entry will
>> accumulate totals for all uses of the prepared statement).  So I'm
>> satisfied with it for now.
>
> Actually, there's an easy hack for that too: we can teach the
> ProcessUtility hook to do nothing (and in particular not increment the
> nesting level) when the statement is an ExecuteStmt.  This will result
> in the executor time being blamed on the original PREPARE, whether or
> not you have enabled tracking of nested statements.  That seems like a
> substantial win to me, because right now you get a distinct EXECUTE
> entry for each textually-different set of parameter values, which seems
> pretty useless.  This change would make use of PREPARE/EXECUTE behave
> very nearly the same in pg_stat_statement as use of protocol-level
> prepared statements.  About the only downside I can see is that the
> cycles expended on evaluating the EXECUTE's parameters will not be
> charged to any pg_stat_statement entry.  Since those can be expressions,
> in principle this might be a non-negligible amount of execution time,
> but in practice it hardly seems likely that anyone would care about it.
>
> Barring objections I'll go fix this, and then this patch can be
> considered closed except for possible future tweaking of the
> sticky-entry decay rule.

After reading your last commit message, I was wondering if something
like this might be possible, so +1 from me.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2012-03-29 20:18:36
Subject: Re: query cache
Previous:From: Tom LaneDate: 2012-03-29 20:05:59
Subject: Re: Re: pg_stat_statements normalisation without invasive changes to the parser (was: Next steps on pg_stat_statements normalisation)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group