Re: Definitive answer: can functions use indexes?

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Seamus Abshere <seamus(at)abshere(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Definitive answer: can functions use indexes?
Date: 2016-01-07 04:19:18
Message-ID: 568DE746.3050006@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/6/16 5:41 PM, Tom Lane wrote:
> Since the question makes little sense as stated, I'm going to assume
> you mean "can a query like SELECT ... WHERE left(foo, 3) = 'bar'
> use an index on column foo?"
>
> The answer to that is no, there is no such optimization built into
> Postgres. (In principle there could be, but I've not heard enough
> requests to make me think we'd ever pursue it.)

BTW, the case where this would be highly valuable is timestamps. Being
able to do something like date_part('month',timestamptz)='Jan' would be
a big, big deal for warehousing.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2016-01-07 04:21:38 Re: Trigger function interface
Previous Message Michael Paquier 2016-01-07 04:01:19 Re: Getting the function definition from oid in before firing the function