Re: Index on timestamp fields - Mailing list pgsql-novice

From Tom Lane
Subject Re: Index on timestamp fields
Date
Msg-id 11650.1181266111@sss.pgh.pa.us
Whole thread Raw
In response to Index on timestamp fields  (David Gardner <David.Gardner@yucaipaco.com>)
Responses Re: Index on timestamp fields  (David Gardner <David.Gardner@yucaipaco.com>)
List pgsql-novice
David Gardner <David.Gardner@yucaipaco.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

pgsql-novice by date:

Previous
From: David Gardner
Date:
Subject: Index on timestamp fields
Next
From: Richard Broersma Jr
Date:
Subject: Re: Index on timestamp fields