pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Teach optimizer's predtest.c more things about ScalarArrayOpExpr
Date: Fri, 01 Mar 2019 22:14:26 +0000
Message-ID: <E1gzqQE-0007DZ-KX@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/65ce07e0202f2ef0953be9d085d3e5df7ad353a4

Modified Files
--------------
src/backend/optimizer/util/predtest.c              | 126 ++++++++--
.../test_predtest/expected/test_predtest.out       | 257 +++++++++++++++++++++
.../modules/test_predtest/sql/test_predtest.sql    | 115 +++++++++
3 files changed, 478 insertions(+), 20 deletions(-)



Message-ID: <E1gzqQE-0007DZ-KX@gemulon.postgresql.org>
Permalink:  ../E1gzqQE-0007DZ-KX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gzqQE-0007DZ-KX@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Teach optimizer's predtest.c more things about ScalarArrayOpExpr
  In-Reply-To: <E1gzqQE-0007DZ-KX@gemulon.postgresql.org>
  References: <E1gzqQE-0007DZ-KX@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox