Re: Improving EXPLAIN's display of SubPlan nodes

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Chantal Keller <chantal(dot)keller(at)universite-paris-saclay(dot)fr>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Improving EXPLAIN's display of SubPlan nodes
Date: 2024-01-22 12:35:33
Message-ID: CAJ7c6TMApZ62NOOk73_BmKkKtdhV+i=tyvXR52DAB-YVuFANDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> EXPLAIN has always been really poor at displaying SubPlan nodes
> in expressions: you don't get much more than "(SubPlan N)".
> This is mostly because every time I thought about it, I despaired
> of trying to represent all the information in a SubPlan accurately.
> However, a recent discussion[1] made me realize that we could do
> a lot better just by displaying the SubLinkType and the testexpr
> (if relevant). So here's a proposed patch. You can see what
> it does by examining the regression test changes.
>
> There's plenty of room to bikeshed about exactly how to display
> this stuff, and I'm open to suggestions.
>
> BTW, I was somewhat depressed to discover that we have exactly
> zero regression coverage of the ROWCOMPARE_SUBLINK code paths;
> not only was EXPLAIN output not covered, but the planner and
> executor too. So I added some simple tests for that. Otherwise
> I think existing coverage is enough for this.

I reviewed the code and tested the patch on MacOS. It looks good to me.

Although something like:

```
+ Filter: (ANY (base_tbl.a = $1) FROM SubPlan 1 (returns $1))
+ SubPlan 1 (returns $1)
```

... arguably doesn't give much more information to the user comparing
to what we have now:

```
- Filter: (SubPlan 1)
- SubPlan 1
```

... I believe this is the right step toward more detailed EXPLAINs,
and perhaps could be useful for debugging and/or educational purposes.
Also the patch improves code coverage.

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-01-22 12:43:38 Re: tablecmds.c/MergeAttributes() cleanup
Previous Message Amit Kapila 2024-01-22 12:26:16 Re: Synchronizing slots from primary to standby