[PATCH] Avoid unnecessary code execution in Instrument.c when TIMING is FALSE

Suzuki Hironobu <hironobu@interdb.jp>

From: Hironobu SUZUKI <hironobu@interdb.jp>
To: pgsql-hackers@postgresql.org
Date: 2025-07-25T15:26:21Z
Lists: pgsql-hackers

Attachments

Hi,

Even when using EXPLAIN ANALYZE with TIMING=FALSE, the functions 
InstrStopNode(), InstrEndLoop(), and InstrAggNode() in Instrument.c 
still execute code related to the "starttime", "counter", "firsttuple", 
"startup",  and "total" fields within the Instrumentation structure.
These operations are unnecessary when timing is disabled, and since 
these functions are called very frequently, I have created a patch to 
address this.

As far as I can tell, this change has no side effects and clarifies the 
intent of each line, but please let me know if you notice any issues.

Best regards,
H.S.