| From: | Tender Wang <tndrwang(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Nicolas Adenis-Lamarre <nicolas(dot)adenis(dot)lamarre(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Planner : anti-join on left joins |
| Date: | 2026-01-01 06:23:22 |
| Message-ID: | CAHewXN=K_CTSzcm8t5ZQZ0TYn1nr+FVosTnoT4TY5EwRoXJL3w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 于2026年1月1日周四 07:37写道:
> Nicolas Adenis-Lamarre <nicolas(dot)adenis(dot)lamarre(at)gmail(dot)com> writes:
> > - detect anti join on "a left join b where x is null" where x is a non
> null
> > var b (b being a rte)
> > this is the object of the attached patched.
>
> This is a perfectly reasonable thing to do, especially now that we've
> built out some infrastructure that would help. It doesn't look like
> your patch is using that though. Take a look at commits 904f6a593
> and e2debb643.
>
Yes, after commits 904f6a593 and e2debb643, we have some infrastructure to
use.
I provided a patch to implement this reduction using these infrastructure
codes.
Please check the attached patch.
>
> BTW, it is not a good look for even a draft patch to not bother
> updating adjacent comments that it falsifies, such as this in
> reduce_outer_joins_pass2:
>
> * See if we can reduce JOIN_LEFT to JOIN_ANTI. This is the case
> if
> * the join's own quals are strict for any var that was forced
> null by
> * higher qual levels. NOTE: there are other ways that we could
> * detect an anti-join, in particular if we were to check whether
> Vars
> * coming from the RHS must be non-null because of table
> constraints.
> * That seems complicated and expensive though (in particular, one
> * would have to be wary of lower outer joins). For the moment this
> * seems sufficient.
>
> In the long run, the comments are as important as the code, if not
> even more so. Keeping them accurate is not optional.
>
I updated the comments in the attached patch as well.
And I test the regression in the src, all tests pass.
Any thoughts?
--
Thanks,
Tender Wang
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Reduce-JOIN_LEFT-TO-JOIN_ANTI.patch | text/plain | 3.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Henson Choi | 2026-01-01 06:45:14 | Re: Row pattern recognition |
| Previous Message | Henson Choi | 2026-01-01 06:16:00 | Re: SQL Property Graph Queries (SQL/PGQ) |