Re: Inefficient query plan for SELECT ... EXCEPT ...

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Dimitrios Apostolou <jimis(at)gmx(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Inefficient query plan for SELECT ... EXCEPT ...
Date: 2023-10-31 22:56:01
Message-ID: CAKFQuwYQUiqx5v96Xq6nAOf9sSwXntP8hwnPBjwiQbJjGiLPMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 31, 2023 at 3:41 PM Dimitrios Apostolou <jimis(at)gmx(dot)net> wrote:

>
> Is this worth a bug report? I can file one if the issue is not known.
> Or am I misunderstanding the implications of the SELECT-EXCEPT query?
>
> In the meantime I have replaced the query with a LEFT OUTER JOIN which
> performs much better,

I'd expect a NOT EXISTS query would also perform well and more accurately
reflect what you seem to be wanting here.

I could see maybe optimizing away the second independent query if the first
produces zero rows but it also doesn't seem like that productive an
optimization to attempt.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Rowley 2023-10-31 22:57:03 Re: Inefficient query plan for SELECT ... EXCEPT ...
Previous Message Dimitrios Apostolou 2023-10-31 22:41:33 Inefficient query plan for SELECT ... EXCEPT ...