Re: Index on timestamp fields

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Gardner <David(dot)Gardner(at)yucaipaco(dot)com>
Cc: Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Index on timestamp fields
Date: 2007-06-08 01:28:31
Message-ID: 11650.1181266111@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

David Gardner <David(dot)Gardner(at)yucaipaco(dot)com> writes:
> I have a timestamp without timezone field in one of my tables that is used =
> in the where clause of one of my queries:
> WHERE date_trunc('day',"backupReports"."start") = current_date

If you can change the query, it'd be better/more efficient to spell this
as
WHERE "backupReports"."start"::date = current_date

Either way, you need to build an index on the expression, not just the
raw column, to make this search fast.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Richard Broersma Jr 2007-06-08 01:33:07 Re: Index on timestamp fields
Previous Message David Gardner 2007-06-08 00:55:56 Index on timestamp fields