Re: Do cast affects index usage?

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Anibal David Acosta <aa(at)devshock(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Do cast affects index usage?
Date: 2012-10-12 20:37:37
Message-ID: CAOR=d=3iBsgKQ_U59Y7Wkcq+7OGgmXXHc76-_HmXkgRxVtdaWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Oct 12, 2012 at 2:05 PM, Anibal David Acosta <aa(at)devshock(dot)com> wrote:
> I have a table with a column of type timestamp with time zone, this column
> has an index
>
> If I do a select like this
>
> select * from mytable where cast(my_date as timestamp without time zone) >
> '2012-10-12 20:00:00'
>
> this query will use the index over the my_date column?

No. but it will use a functional index:

create index yada on blah (cast(my_date as timestaqmp without time zone));

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2012-10-12 20:38:31 Re: Do cast affects index usage?
Previous Message Anibal David Acosta 2012-10-12 20:05:52 Do cast affects index usage?