Re: extract(year from date) doesn't use index but maybe could? - Mailing list pgsql-performance

From Yves Dorfsman
Subject Re: extract(year from date) doesn't use index but maybe could?
Date
Msg-id 5534269A.10605@zioup.com
Whole thread Raw
In response to Re: extract(year from date) doesn't use index but maybe could?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: extract(year from date) doesn't use index but maybe could?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
On 2015-04-19 15:33, Tom Lane wrote:
>
>> It's possible that in the future someone will implement an optimization
>> like this, but I'm not aware of anyone working on that and I wouldn't
>> hold my breath.
>
> Yeah.  In principle you could make the planner do this.  As Adam Williams
> notes nearby, there's a problem with lack of exact consistency between
> extract() semantics and straight timestamp comparisons; but you could
> handle that by extracting indexable expressions that are considered lossy,

What about functions that are simpler such as upper()/lower()?

On 9.3, this:
`select email from users where lower(first_name) = 'yves';

is not using the index on first_name (Seq Scan on first_name). This should be
easy to implement?

--
http://yves.zioup.com
gpg: 4096R/32B0F416



pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: extract(year from date) doesn't use index but maybe could?
Next
From: Tom Lane
Date:
Subject: Re: extract(year from date) doesn't use index but maybe could?