Re: explain plans for foreign servers

From: Dinesh Salve <cooltodinesh(at)gmail(dot)com>
To: solai v <solai(dot)cdac(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: 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-08-05 10:47:51
Message-ID: CAP+B4TC_06iSx8cBTLP9KHaC2DHEfvx8A6n7T=ZYFHiyHWe-5Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks a lot Solai for testing the patch, appreciate it.

Hi Bharath,
Thanks for the inputs, attached v7 patch to make review easier.

> IMO, we don't need to print all the flavors of explain plans
I have removed formatting related tests from file postgres_fdw.sql and
moved to a separate file remote_plans_formats.sql.
We still need tests around formatting as my changes introduce some new
elements.

> Another point, why are we not supporting explain analyze?
This will be part of follow-up work, I wanted agreement on the shape first
from the community.
One design I considered is an auto_explain-style GUC asking the remote to
emit the plan for the statement it is already
running, but we cannot assume an arbitrary foreign server has that, so it
needs a fallback and more thought.

> 1/ Why not get the extension id at once in _PG_init
Fixed, also I moved all the EXPLAIN plumbing into postgres_fdw.c behind
postgres_fdw_explain_init(), called from
_PG_init. The extension id, the saved hook pointers and both hook
functions are now static.

Addressed other comments regarding documentation around GENERIC_PLAN option
and added error case handling non-existent remote table.

Attachment Content-Type Size
v7-0001-postgres_fdw-show-remote-EXPLAIN-plans-via-REMOTE.patch application/octet-stream 45.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-08-05 11:05:33 Re: pgstat: Flush some statistics within running transactions, take 2
Previous Message ZizhuanLiu X-MAN 2026-08-05 10:44:46 Re: Fix var_eq_const: sum selectivity of all matching MCV entries instead of stopping at first match