Re: RFC: Logging plan of the running query
torikoshia <torikoshia@oss.nttdata.com>
From: torikoshia <torikoshia@oss.nttdata.com>
To: Atsushi Torikoshi <torikoshia.tech@gmail.com>, robertmhaas@gmail.com
Cc: pgsql-hackers@lists.postgresql.org, samimseih@gmail.com,
destrex271@gmail.com
Date: 2025-06-02T12:56:38Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
ecpg: Catch zero-length Unicode identifiers correctly
- a18b6d2dc288 15.0 cited
-
Improve warning message in pg_signal_backend()
- 7fa945b857cc 15.0 cited
-
Add assert to ensure that page locks don't participate in deadlock cycle.
- 72e78d831ab5 13.0 cited
Attachments
- v45-0001-Add-function-to-log-the-plan-of-the-currently-ru.patch (text/x-diff) patch v45-0001
On 2025-05-23 17:50, Atsushi Torikoshi wrote: > Thanks for the idea and the sample patch! > Agreed. I’ll go ahead and implement a new patch based on this approach. Updated the patch. Here are some notes: As with the previous patches, this one wraps not only the currently executing plan node but also recursively wraps the left, right, and child nodes' ExecProcNode with ExecProcNodeFirst. This is because modifying only the currently executing node caused significant delays in plan logging when the left, right, or child nodes took a long time to execute. I observed the situation with the following query: SELECT count(*) FROM pgbench_accounts a CROSS JOIN pgbench_accounts b; Previous patches implemented unwrappers, but this one doesn’t. This is because once the log is output, GetProcessLogQueryPlanInterruptActive() returns false, so LogQueryPlan() will no longer be called. In the sample you previously provided, the LogQueryPlan function takes a PlanState as an argument, but in this patch, it’s defined as void. I made this change under the assumption that the plan can be obtained from ActiveQueryDesc, and that PlanState is therefore unnecessary. Please let me know if I’ve misunderstood anything. Regards, -- Atsushi Torikoshi Seconded from NTT DATA GROUP CORPORATION to SRA OSS K.K.