On Tue, Nov 13, 2018 at 10:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Richard Guo <riguo@pivotal.io> writes: > Currently for quals in the form of "NOT NOT (SubLink)", this SubLink would > not be considered when pulling up sublinks.
Yup. > Should we give it a chance, like the attached does?
What is the argument that this occurs often enough to be worth expending extra cycles and code space on?
If we do do something like this, I'd be inclined to make it handle any-number-of-consecutive-NOTs, and maybe remove NOT NOT over an ANY, not just EXISTS. But I don't honestly think that it's worth troubling over. Do even the dumbest ORMs generate such code?
What this patch does is to recursively remove NOT NOT over a SubLink, so it
actually can handle any-number-of-consecutive-NOTs, both over ANY and over EXISTS.
Over ANY:
gpadmin=# explain select * from a where not not not not a.i in (select i from b);