[RFC PATCH v1] Add EXPLAIN ANALYZE wait event reporting

From: r314tive <tanswis42(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: [RFC PATCH v1] Add EXPLAIN ANALYZE wait event reporting
Date: 2026-05-14 11:19:45
Message-ID: CALCfnuquuxtZmmzQBZ_yxaihfj7bnALXdzi9Nj=RYUW4iwY6GQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Following Michael Paquier's note about PostgreSQL list practice, this v1
resends the same patch content as v0 as a single email with the patch series
attached.

No code changes from v0.

v0 thread:
https://www.postgresql.org/message-id/cover.1778280923.git.tanswis42%40gmail.com

This RFC prototype adds EXPLAIN (ANALYZE, WAITS), which reports completed
wait
intervals observed through pgstat_report_wait_start/end().

Statement-level wait events are counted once per active statement collector.
Plan-node wait events use inclusive attribution, similar to EXPLAIN ANALYZE
timing: a completed wait is attributed to every active plan node captured
when
the wait begins. Per-node wait times therefore must not be summed across
plan
nodes.

The patch series is split as follows:

1. Add statement-level EXPLAIN WAITS reporting.
2. Aggregate statement-level EXPLAIN WAITS from parallel workers.
3. Attribute EXPLAIN WAITS to plan nodes.
4. Refine attribution semantics, documentation, and regression coverage.
5. Harden accumulator handling with fixed-size, allocation-free storage.
6. Hide accumulator internals from public headers.
7. Keep psql EXPLAIN option completion current.

The main review questions are:

- whether the option should be named WAITS or WAIT_EVENTS;
- whether inclusive per-node attribution is the right initial semantics;
- whether the fixed accumulator limit and overflow reporting are acceptable;
- whether the disabled/enabled hot-path overhead is acceptable.

Regards,
Ilmar

Attachment Content-Type Size
0001-Add-EXPLAIN-WAITS-statement-reporting.patch application/octet-stream 17.9 KB
0002-Aggregate-EXPLAIN-WAITS-from-parallel-workers.patch application/octet-stream 17.0 KB
0003-Attribute-EXPLAIN-WAITS-to-plan-nodes.patch application/octet-stream 35.0 KB
0004-Refine-EXPLAIN-WAITS-attribution-semantics.patch application/octet-stream 42.8 KB
0005-Harden-EXPLAIN-WAITS-accumulator-handling.patch application/octet-stream 10.6 KB
0006-Hide-EXPLAIN-WAITS-accumulator-internals.patch application/octet-stream 14.5 KB
0007-Keep-EXPLAIN-option-completion-current.patch application/octet-stream 1.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2026-05-14 11:35:30 Re: Import Statistics in postgres_fdw before resorting to sampling.
Previous Message Nitin Motiani 2026-05-14 11:12:33 [PATCH] Fix for bug #19474: LIKE fails to match literal backslashes with nondeterministic collations