Postgres 19 introduces a significant reduction in EXPLAIN ANALYZE timing overhead by switching from the RDTSCP CPU instruction to RDTSC for instrumentation measurements. RDTSCP serializes instruction execution (blocking out-of-order execution), while RDTSC does not, resulting in roughly 50% lower per-measurement overhead. In practice, a COUNT(*) over 50M rows that took ~800ms with the old system clock source now takes ~355ms with the new TSC clock source. A new `timing_clock_source` setting (values: auto, system, tsc) lets users control this behavior. The change makes it practical to enable `auto_explain.log_timing` on more production workloads, reducing average overhead from 5-10% down to roughly 2-3%. The feature targets x86-64 initially; ARM support has outstanding issues. It was committed to the Postgres 19 development branch and is expected in the September/October 2025 release.
Table of contents
The problem of slow timing measurementsRDTSC vs RDTSCPThe new timing_clock_source Postgres settingLive demo on Postgres 19 development branchWhat we have discussed in this episode of 5mins of PostgresSort: