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@postgresql.org
Subject: pgsql: Fix matching of boolean index columns to sort ordering.
Date: Sun, 15 Jan 2017 19:09:45 +0000
Message-ID: <E1cSqBV-000147-7d@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Fix matching of boolean index columns to sort ordering.

Normally, if we have a WHERE clause like "indexcol = constant",
the planner will figure out that that index column can be ignored
when determining whether the index has a desired sort ordering.
But this failed to work for boolean index columns, because a
condition like "boolcol = true" is canonicalized to just "boolcol"
which does not give rise to an EquivalenceClass.  Add a check to
allow the same type of deduction to be made in this case too.

Per a complaint from Dima Pavlov.  Arguably this is a bug, but given the
limited impact and the small number of complaints so far, I won't risk
destabilizing plans in stable branches by back-patching.

Patch by me, reviewed by Michael Paquier

Discussion: https://postgr.es/m/1788.1481605684@sss.pgh.pa.us

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0777f7a2e8e0a51f0f60cfe164d538bb459bf9f2

Modified Files
--------------
src/backend/optimizer/path/indxpath.c      | 46 ++++++++++++++++++++++++++++++
src/backend/optimizer/path/pathkeys.c      | 35 ++++++++++++++++-------
src/include/optimizer/paths.h              |  2 ++
src/test/regress/expected/create_index.out | 42 +++++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 15 ++++++++++
5 files changed, 129 insertions(+), 11 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1cSqBV-000147-7d@gemulon.postgresql.org>
Permalink:  ../E1cSqBV-000147-7d@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1cSqBV-000147-7d@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: Fix matching of boolean index columns to sort ordering.
  In-Reply-To: <E1cSqBV-000147-7d@gemulon.postgresql.org>
  References: <E1cSqBV-000147-7d@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