• Tom Lane's avatar
    Teach optimizer's predtest.c more things about ScalarArrayOpExpr. · 65ce07e0
    Tom Lane authored
    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
    65ce07e0
test_predtest.out 23.3 KB