| From: | Dinesh Salve <cooltodinesh(at)gmail(dot)com> |
|---|---|
| To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
| Cc: | solai v <solai(dot)cdac(at)gmail(dot)com>, Sami Imseih <samimseih(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Jeff Davis <pgsql(at)j-davis(dot)com>, Yilin Zhang <jiezhilove(at)126(dot)com> |
| Subject: | Re: explain plans for foreign servers |
| Date: | 2026-09-13 14:14:48 |
| Message-ID: | CAP+B4TB3BMJqxkgyhBSE3Kg=QQ-ay6+9oWGykNn7JgY-9yuvYA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Bharath,
> Having the remote EXPLAIN support first makes sense. However, having a
> high-level design for EXPLAIN ANALYZE support would make the feature
> more concrete.
In this thread, a possible high level design for EXPLAIN ANALYZE support
was discussed and here is the one of approach. Idea is to capture the plan
of the remote statement that postgres_fdw already executes, rather than
issuing a separate remote EXPLAIN ANALYZE. The remote backend could use an
auto_explain style facility to retain the completed plan, including runtime
statistics, at ExecutorEnd or when the FDW cursor is closed.
After completing the remote query, postgres_fdw would either -
1. issue a separate statement to retrieve that stored plan and associate it
with the corresponding local plan-node ID.
2. Or a new guc set on remote connection can request remote Postgresql to
transport the plan through NOTICE.
Transporting the plan through NOTICE is fragile, while returning an
additional result set conflicts with the extended query protocol, so a
dedicated retrieval function from approach 1 or separate protocol mechanism
for this would be preferable. This design would require explicit capability
detection on remote PostgreSQL server. GENERIC_PLAN is only an additional
constraint for queries containing placeholders: it need not be combined
with ANALYZE as here we capture the actual plan using the bound parameter
values from the original remote execution.
I am proposing we expose the remote_plans option now as that feature itself
would make our user's life a bit easy and in parallel I will groom this
design approach on top of other suggestions if any.
Updated the patch to add `GENERIC_PLAN` only when the remote SQL contains
parameter placeholders. Placeholder detection uses fdw_exprs as suggested.
Thank,
Dinesh
| Attachment | Content-Type | Size |
|---|---|---|
| v8-0001-postgres_fdw-show-remote-EXPLAIN-plans-via-REMOTE.patch | application/octet-stream | 49.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-09-13 14:54:58 | Re: [BUG] ON CONFLICT DO UPDATE SET x = EXCLUDED.<virtual-generated-column> errors or silently writes NULL |
| Previous Message | Konstantin Knizhnik | 2026-09-13 13:30:53 | Recovery at replica stuck because recovery incorrectly trusts an old high-water mark |