Re: NOT IN subquery optimization
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "Li, Zheng" <zhelli@amazon.com>, Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Richard Guo <riguo@pivotal.io>, "Finnerty, Jim" <jfinnert@amazon.com>
Date: 2019-03-02T13:34:20Z
Lists: pgsql-hackers
On Sat, 2 Mar 2019 at 13:45, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > David Rowley <david.rowley@2ndquadrant.com> writes: > > I think you're fighting a losing battle here with adding OR quals to > > the join condition. > > Yeah --- that has a nontrivial risk of making things significantly worse, > which makes it a hard sell. I think the most reasonable bet here is > simply to not perform the transformation if we can't prove the inner side > NOT NULL. That's going to catch most of the useful cases anyway IMO. Did you mean outer side NOT NULL? The OR col IS NULL was trying to solve the outer side nullability problem when the inner side is empty. Of course, the inner side needs to not produce NULLs either, but that's due to the fact that if a NULL exists in the inner side then the anti-join should not produce any records. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Commits
-
Check we don't misoptimize a NOT IN where the subquery returns no rows.
- 3396138a6de3 12.0 landed