Re: Do cast affects index usage?

From: "Anibal David Acosta" <aa(at)devshock(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Do cast affects index usage?
Date: 2012-10-13 00:27:42
Message-ID: 000001cda8d9$913a7770$b3af6650$@devshock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Because I need to get all rows where datetime is greater than (for example)
'2012-10-10 00:00:00' but ignoring timezone, so basically I need to truncate
timezone
This can be done by converting to timestamp without timezone.

-----Mensaje original-----
De: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Enviado el: viernes, 12 de octubre de 2012 05:39 p.m.
Para: Anibal David Acosta
CC: pgsql-performance(at)postgresql(dot)org
Asunto: Re: [PERFORM] Do cast affects index usage?

"Anibal David Acosta" <aa(at)devshock(dot)com> writes:
> 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. The cast seems rather pointless though ...

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2012-10-13 01:31:54 Re: problems with large objects dump
Previous Message Tom Lane 2012-10-12 23:18:43 Re: problems with large objects dump