Re: Anti join confusion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Tender Wang <tndrwang(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Anti join confusion
Date: 2025-02-27 01:55:33
Message-ID: 2320071.1740621333@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Wed, Feb 26, 2025 at 4:58 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Yeah. The key problem blocking doing something about it in the
>> planner is that at the time we want to do join tree restructuring,
>> we haven't yet collected the per-relation data that would allow
>> us to know about NOT NULL constraints, nor run expression
>> simplification that would be important for detecting all but the
>> most basic cases. Doing either of those things twice seems like
>> a nonstarter from a planner-speed viewpoint. It's possible that
>> we could rearrange things to collect catalog data sooner.
>> (I'm vaguely imagining that we'd collect that stuff by relation
>> OID to begin with, and then when we build RelOptInfos later on
>> we could link to the per-rel-OID catalog data.) Moving expression
>> simplification up seems considerably more fraught, but maybe we could
>> handle the cases of common interest without having done that.

> Oh, this is very helpful! I didn't realize that there were specific
> technical obstacles standing in the way of making this happen; I was
> assuming it was just a case of nobody having been interested enough to
> write the code. That's good to know.

Well, there's that too ;-). I would not be suggesting something
requiring significant planner restructuring if the only benefit
were to be able to turn some instances of NOT IN into antijoins.
But I think having NOT NULL info available earlier might allow
removal of some nasty kluges (I'm looking at you,
restriction_is_always_true).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-02-27 02:16:22 Re: Anti join confusion
Previous Message Robert Haas 2025-02-27 01:39:04 Re: Anti join confusion