Re: explain plans for foreign servers - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: explain plans for foreign servers
Date
Msg-id 07147023882ac6c4424df946fd4b82b8e8c211a5.camel@j-davis.com
Whole thread Raw
In response to Re: explain plans for foreign servers  (Sami Imseih <samimseih@gmail.com>)
Responses Re: explain plans for foreign servers
List pgsql-hackers
On Wed, 2025-02-26 at 13:13 -0600, Sami Imseih wrote:
> 1/ The use of NOTICE to propagate the explain plan.
> I see the message content is checked, but this does not look robust
> and could lead to
> some strange results if another ExecutorRun hook emits a similar
> notice message.

Fundamentally, EXPLAIN ANALYZE needs to return two result sets for this
patch to work: the ordinary result, and the EXPLAIN ANALYZE result. The
current patch hacks around that by returning the ordinary result set
from the foreign server, and then returning the EXPLAIN ANALYZE result
as a NOTICE.

Ideally, we'd have EXPLAIN ANALYZE return two result sets, kind of like
how a query with a semicolon returns two result sets. That changes the
expected message flow for EXPLAIN ANALYZE, though, so we'd need a new
option so we are sure the client is expecting it (is this a sane
idea?). I wonder if Robert's extensible EXPLAIN work[1] could be useful
here? We'd also need a DestReceiver capable of returning two result
sets. These problems sound solvable, but would require some more
discussion.

> What if we do something like a new EXPLAIN option which returns all
> the rows
> back to the client, and then writes out the plan to some local
> memory.

That's another idea, but I am starting to think returning two result
sets from EXPLAIN ANALYZE would be generally useful.

Regards,
    Jeff Davis

[1]
https://www.postgresql.org/message-id/CA%2BTgmoYSzg58hPuBmei46o8D3SKX%2BSZoO4K_aGQGwiRzvRApLg%40mail.gmail.com





pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: making EXPLAIN extensible
Next
From: Tom Lane
Date:
Subject: Re: explain plans for foreign servers