Re: extract(year from date) doesn't use index but maybe could?

From: Yves Dorfsman <yves(at)zioup(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: extract(year from date) doesn't use index but maybe could?
Date: 2015-04-19 22:05:14
Message-ID: 5534269A.10605@zioup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2015-04-19 22:29:54 Re: extract(year from date) doesn't use index but maybe could?
Previous Message Tom Lane 2015-04-19 21:33:11 Re: extract(year from date) doesn't use index but maybe could?