pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Dimitrios Apostolou <jimis@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Inefficient query plan for SELECT ... EXCEPT ...
Date: Tue, 31 Oct 2023 20:52:07 -0400
Message-ID: <2664450.1698799927@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvogxAy+RFSQ+-h7BO-Bu0LoHf0kmV7cPdb9WypRserv8g@mail.gmail.com>
References: <86c352b6-c0ec-8c4d-9506-297506b1b5da@gmx.net>
	<CAApHDvogxAy+RFSQ+-h7BO-Bu0LoHf0kmV7cPdb9WypRserv8g@mail.gmail.com>

David Rowley <dgrowleyml@gmail.com> writes:
> It would be possible to have some sort of MergeExcept operator and
> have the planner consider that. Unfortunately, since the upper planner
> was changed a few years ago to have it consider paths the same as the
> join planner does, nobody has yet come back to the union planner to
> properly pathify that.  I do have a WIP patch to do this work, but I
> wasn't planning on improving EXCEPT, only UNION. Making it work for
> EXCEPT and INTERSECT would require a new executor operator.

Yeah.  We're moderately good about UNION ALL, but UNION/INTERSECT/EXCEPT
are an area that nobody has ever gotten around to optimizing: the two
sub-queries will be planned independently and then fed to a simplistic
set-operation node.  Maybe that'll get better someday but don't hold
your breath.  In the meantime, try to recast an EXCEPT query as an
antijoin.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <2664450.1698799927@sss.pgh.pa.us>
Permalink:  ../2664450.1698799927@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2664450.1698799927@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, jimis@gmx.net
  Subject: Re: Inefficient query plan for SELECT ... EXCEPT ...
  In-Reply-To: <2664450.1698799927@sss.pgh.pa.us>
  References: <86c352b6-c0ec-8c4d-9506-297506b1b5da@gmx.net> <CAApHDvogxAy+RFSQ+-h7BO-Bu0LoHf0kmV7cPdb9WypRserv8g@mail.gmail.com> <2664450.1698799927@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox