postgresql/contrib/pg_stat_statements
Tom Lane e0e4ebe384 Improve handling of utility statements containing plannable statements.
When tracking nested statements, contrib/pg_stat_statements formerly
double-counted the execution costs of utility statements that directly
contain an executable statement, such as EXPLAIN and DECLARE CURSOR.
This was not obvious since the ProcessUtility and Executor hooks
would each add their measured costs to the same stats table entry.
However, with the new implementation that hashes utility and plannable
statements differently, this showed up as seemingly-duplicate stats
entries.  Fix that by disabling the Executor hooks when the query has a
queryId of zero, which was the case already for such statements but is now
more clearly specified in the code.  (The zero queryId was causing problems
anyway because all such statements would add to a single bogus entry.)

The PREPARE/EXECUTE case still results in counting the same execution
in two different stats table entries, but it should be much less surprising
to users that there are two entries in such cases.

In passing, include a CommonTableExpr's ctename in the query hash.
I had left it out originally on the grounds that we wanted to omit all
inessential aliases, but since RTE_CTE RTEs are hashing their referenced
names, we'd better hash the CTE names too to make sure we don't hash
semantically different queries the same.
2012-03-29 15:32:59 -04:00
..
Makefile Make EXPLAIN (BUFFERS) track blocks dirtied, as well as those written. 2012-02-22 20:33:05 -05:00
pg_stat_statements--1.0--1.1.sql Expose track_iotiming information via pg_stat_statements. 2012-03-27 15:18:49 -04:00
pg_stat_statements--1.0.sql Throw a useful error message if an extension script file is fed to psql. 2011-10-12 15:45:03 -04:00
pg_stat_statements--1.1.sql Expose track_iotiming information via pg_stat_statements. 2012-03-27 15:18:49 -04:00
pg_stat_statements--unpackaged--1.0.sql Throw a useful error message if an extension script file is fed to psql. 2011-10-12 15:45:03 -04:00
pg_stat_statements.c Improve handling of utility statements containing plannable statements. 2012-03-29 15:32:59 -04:00
pg_stat_statements.control Make EXPLAIN (BUFFERS) track blocks dirtied, as well as those written. 2012-02-22 20:33:05 -05:00