Re: NOT IN subquery optimization - Mailing list pgsql-hackers

From David Rowley
Subject Re: NOT IN subquery optimization
Date
Msg-id CAKJS1f-ga5mVXCDJ92qTK8nC-oYfWRTr0xR9NAKiP2v216EfHg@mail.gmail.com
Whole thread Raw
In response to Re: NOT IN subquery optimization  (Jim Finnerty <jfinnert@amazon.com>)
Responses Re: NOT IN subquery optimization  ("Li, Zheng" <zhelli@amazon.com>)
Re: NOT IN subquery optimization  (Richard Guo <riguo@pivotal.io>)
List pgsql-hackers
On Wed, 27 Feb 2019 at 03:07, Jim Finnerty <jfinnert@amazon.com> wrote:
>
> The problem is that the special optimization that was proposed for the case
> where the subquery has no WHERE clause isn't valid when the subquery returns
> no rows.  That additional optimization needs to be removed, and preferably
> replaced with some sort of efficient run-time test.

That is one option, however, the join type that Richard mentions, to
satisfy point #3, surely only can work for Hash joins and perhaps
Merge joins that required a sort, assuming there's some way for the
sort to communicate about if it found NULLs or not. Either way, we
need to have looked at the entire inner side to ensure there are no
nulls. Probably it would be possible to somehow team that up with a
planner check to see if the inner exprs could be NULL then just
implement points #1 and #2 for other join methods.

If you're proposing to do that for this thread then I can take my
planner only patch somewhere else.  I only posted my patch as I pretty
much already had what I thought you were originally talking about.
However, please be aware there are current patents around adding
execution time smarts in this area, so it's probably unlikely you'll
find a way to do this in the executor that does not infringe on those.
Probably no committer would want to touch it.  I think my patch covers
a good number of use cases and as far as I understand, does not go
near any current patents.

Please let me know if I should move my patch to another thread. I
don't want to hi-jack this if you're going in another direction.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Remove Deprecated Exclusive Backup Mode
Next
From: Paul Ramsey
Date:
Subject: Re: Allowing extensions to supply operator-/function-specific info