Re: Buffer usage in EXPLAIN and pg_stat_statements (review)

Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>

From: Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>, Euler Taveira de Oliveira <euler@timbira.com>, Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2009-10-14T08:44:22Z
Lists: pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> 2. I do not understand the stuff with propagating counts into the top
> instrumentation node.  That seems like it's going to double-count those
> counts.  In any case it is 100% inconsistent to propagate only buffer
> counts that way and not any other resource usage.  I think you should
> drop the TopInstrument variable and the logic that propagates counts up.

It is required by contrib/pg_stat_statements. EXPLAIN wants per-node
accumulation, but pg_stat_statements wants the total number.

Is it enough to add a PG_TRY block to standard_ExecutorRun() to
cleanup TopInstrument on error? I'm working on your other comments,
but I cannot remove TopInstrument for pg_state_statements.

I considerd other approaches, but all of them require node-dependent
routines; for example, adding a function to walk through a plan tree
and accumulate instrumentations in it at pg_stat_statements. But it is
hard to be maintained on executor nodes changes. Are there any better idea?

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center