Re: timestamp interval issue - Mailing list pgsql-novice

From Michael Glaesemann
Subject Re: timestamp interval issue
Date
Msg-id 0FA3DD0A-3BA9-4F70-A2B1-5C3A7BAE39A8@seespotcode.net
Whole thread Raw
In response to Re: timestamp interval issue  (Nis Jørgensen <nis@superlativ.dk>)
List pgsql-novice
On Oct 8, 2007, at 6:14 , Nis Jørgensen wrote:

> Nis Jørgensen skrev:
>> SELECT *
>> FROM footable0
>> WHERE (date_created - interval '16 hours')::date = (now() -
>> interval '16
>> hours')::date;
>>
>> Tested.
>
> Unfortunately, the performance is horrible - it is using a seqscan.

You can create a functional index to improve performance here,
something like

create index rectified_created_at_idx on mytable (cast (created_at -
interval '16 hours') to date);

I haven't thought it through, but you may run into issues with time
zones -- this is not particular to this solution however.

Michael Glaesemann
grzm seespotcode net



pgsql-novice by date:

Previous
From: Nis Jørgensen
Date:
Subject: Re: timestamp interval issue
Next
From: "Justin Vassallo"
Date:
Subject: is my pgsql 32 or 64 bit?