Re: Strange logic for partial index proving

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange logic for partial index proving
Date: 2005-06-21 20:29:25
Message-ID: 16775.1119385765@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndquadrant(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-06-21 20:30:20 Re: Function's LEAST, GREATEST and DECODE (Oracle vararg
Previous Message Tom Lane 2005-06-21 20:26:30 Re: Function's LEAST, GREATEST and DECODE (Oracle vararg