Re: Strange logic for partial index proving - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Strange logic for partial index proving
Date
Msg-id 16775.1119385765@sss.pgh.pa.us
Whole thread Raw
In response to Strange logic for partial index proving  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: Strange logic for partial index proving
List pgsql-hackers
Simon Riggs <simon@2ndquadrant.com> writes:
> Sweating over the logic of the theorem prover, I notice it doesn't
> actually bother to complete an accurate test.

Sure it does.

> create index idx1 on tenk (col1) where col1 > 1 and col1 < 10;

> explain select * from tenk where col1 > 5 and col1 < -5;
> [ uses that index ]

This is a perfectly legitimate situation.  "col1 > 5" implies "col1 > 1"
and "col1 < -5" implies "col1 < 10", therefore the query WHERE condition
implies the index predicate, therefore the index contains all tuples
that could pass the WHERE condition, therefore the index is usable.

Kindly do not break this.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Space reuse and autovacuum
Next
From: Tom Lane
Date:
Subject: Re: PROPOSAL FE/BE extension to handle IN/OUT parameters