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

From: Hironobu SUZUKI <hironobu(at)interdb(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Avoid unnecessary code execution in Instrument.c when TIMING is FALSE
Date: 2025-07-25 15:26:21
Message-ID: df1eb648-b0b7-496d-b047-d7a7a157b2c7@interdb.jp
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Attachment Content-Type Size
v1_avoid_unnecessary_code_execution_in_instrumentation.patch text/plain 2.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-07-25 15:29:01 Re: track generic and custom plans in pg_stat_statements
Previous Message Tom Lane 2025-07-25 15:02:28 Re: HASH_FIXED_SIZE flag gets lost when attaching to existing hash table