]> granicus.if.org Git - postgresql/commit
Teach optimizer's predtest.c more things about ScalarArrayOpExpr.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 1 Mar 2019 22:14:07 +0000 (17:14 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 1 Mar 2019 22:14:17 +0000 (17:14 -0500)
commit65ce07e0202f2ef0953be9d085d3e5df7ad353a4
treef67180f99cd3bb6d6a170cc197bfb7da7a267b53
parentaad21d4c3cd84e7c2a28d239048d2e2f494be47e
Teach optimizer's predtest.c more things about ScalarArrayOpExpr.

In particular, make it possible to prove/refute "x IS NULL" and
"x IS NOT NULL" predicates from a clause involving a ScalarArrayOpExpr
even when we are unable or unwilling to deconstruct the expression
into an AND/OR tree.  This avoids a former unexpected degradation of
plan quality when the size of an ARRAY[] expression or array constant
exceeded the arbitrary MAX_SAOP_ARRAY_SIZE limit.  For IS-NULL proofs,
we don't really care about the values of the individual array elements;
at most, we care whether there are any, and for some common cases we
needn't even know that.

The main user-visible effect of this is to let the optimizer recognize
applicability of partial indexes with "x IS NOT NULL" predicates to
queries with "x IN (array)" clauses in some cases where it previously
failed to recognize that.  The structure of predtest.c is such that a
bunch of related proofs will now also succeed, but they're probably
much less useful in the wild.

James Coleman, reviewed by David Rowley

Discussion: https://postgr.es/m/CAAaqYe8yKSvzbyu8w-dThRs9aTFMwrFxn_BkTYeXgjqe3CbNjg@mail.gmail.com
src/backend/optimizer/util/predtest.c
src/test/modules/test_predtest/expected/test_predtest.out
src/test/modules/test_predtest/sql/test_predtest.sql