Hi,
Here's a slightly improved v5, with a couple minor changes over v4.
Patches 0001 and 0002 are prerequisites from other threads. 0001 was
already included in v4. 0002 is new and comes from [1], and it adds
"flags" to TAM beginscan() methods. This allows 0003 to pass a new
SO_SCAN_INSTRUMENT flag, so that e.g. heap_beginscan() can initialize
the instrumentation only when executed in EXPLAIN ANALYZE. In v4 it had
to be done every time, which did not seem quite great.
This mimics what we do for index scans in the index prefetching, which
only allocates the instrumentation when needed.
0004 and 0005 are adjusted to do this for SeqScan and TidRangeScans too.
0006 is a minor adjustment of the explain output, based on the earlier
discussion about non-text formats. It removes the explain groups (to not
add nested output), and instead makes the labels more descriptive. It
also prints the items every time, even with io_count==0.
The last change is that I added the number of I/Os, instead of printing
just the number of stalls and average I/O size. Without the count it
seemed a bit difficult to interpret. It might be possible to deduce some
of this from buffers reads, but I found it a bit unclear.
0006 should be split and merged into the earlier parts, I mostly kept it
to make those changes obvious.
regards
https://www.postgresql.org/message-id/itvgqc6vncbjsjfmrptfvkkeg5vqzhalaguya2z77t6c6ctpc3%40wsdrgbn4bxaa
--
Tomas Vondra