postgresql/src/include/executor
Andres Freund 2c16deee2f instrumentation: Allocate query level instrumentation in ExecutorStart
Until now extensions that wanted to measure overall query execution could
create QueryDesc->totaltime, which the core executor would then start and
stop.  That's a bit odd and composes badly, e.g. extensions always had to use
INSTRUMENT_ALL, because otherwise another extension might not get what they
need.

Instead this introduces a new field, QueryDesc->query_instr_options, that
extensions can use to indicate whether they need query level instrumentation
populated, and with which instrumentation options. Extensions should take care
to only add options they need, instead of replacing the options of others.

The prior name of the field, totaltime, sounded like it would only measure
time, but these days the instrumentation infrastructure can track more
resources.  The secondary benefit is that this will make it obvious to
extensions that they may not create the Instrumentation struct themselves
anymore (often extensions build only against a postgres build without
assertions).

Adjust pg_stat_statements and auto_explain to match, and lower the
requested instrumentation level for auto_explain to INSTRUMENT_TIMER,
since the summary instrumentation it needs is only runtime.

The reason to push this now, rather in the PG 20 cycle, is that 5a79e78501
already required extensions using query level instrumentations to adjust their
code, and it seemed undesirable to require them to do so again for 20.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53Pkyqsht+exJQYRsjhSWYKu+vFGHhPub7m6PmFD6Or0=p1g@mail.gmail.com
2026-04-08 00:06:45 -04:00
..
execAsync.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
execdebug.h Adjust style of some debugging macros. 2026-02-06 16:24:21 -06:00
execdesc.h instrumentation: Allocate query level instrumentation in ExecutorStart 2026-04-08 00:06:45 -04:00
execExpr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
execParallel.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
execPartition.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
execScan.h Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
executor.h instrumentation: Move ExecProcNodeInstr to allow inlining 2026-04-07 21:36:49 -04:00
functions.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
hashjoin.h Improve hash join's handling of tuples with null join keys. 2026-03-19 15:21:36 -04:00
instrument.h Add EXPLAIN (IO) infrastructure with BitmapHeapScan support 2026-04-07 22:33:34 +02:00
instrument_node.h Add EXPLAIN (IO) instrumentation for TidRangeScan 2026-04-07 23:25:05 +02:00
nodeAgg.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeAppend.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeBitmapAnd.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeBitmapHeapscan.h Fix BitmapHeapScan non-parallel-aware EXPLAIN ANALYZE 2026-04-07 12:47:13 +02:00
nodeBitmapIndexscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeBitmapOr.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeCtescan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeCustom.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeForeignscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeFunctionscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeGather.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeGatherMerge.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeGroup.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeHash.h Improve hash join's handling of tuples with null join keys. 2026-03-19 15:21:36 -04:00
nodeHashjoin.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeIncrementalSort.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeIndexonlyscan.h Allocate separate DSM chunk for parallel Index[Only]Scan instrumentation 2026-04-06 19:10:19 -04:00
nodeIndexscan.h Allocate separate DSM chunk for parallel Index[Only]Scan instrumentation 2026-04-06 19:10:19 -04:00
nodeLimit.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeLockRows.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeMaterial.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeMemoize.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeMergeAppend.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeMergejoin.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeModifyTable.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeNamedtuplestorescan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeNestloop.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeProjectSet.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeRecursiveunion.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeResult.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeSamplescan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeSeqscan.h Add EXPLAIN (IO) instrumentation for SeqScan 2026-04-07 23:07:03 +02:00
nodeSetOp.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeSort.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeSubplan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeSubqueryscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeTableFuncscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeTidrangescan.h Add EXPLAIN (IO) instrumentation for TidRangeScan 2026-04-07 23:25:05 +02:00
nodeTidscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeUnique.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeValuesscan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeWindowAgg.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
nodeWorktablescan.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
spi.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
spi_priv.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tablefunc.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tqueue.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tstoreReceiver.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
tuptable.h Optimize tuple deformation 2026-03-16 11:46:00 +13:00