Re: [GENERAL] selecting rows older than X, ensuring index is used

2005-08-20 Thread Tom Lane
Oliver Elphick writes: > On Sat, 2005-08-20 at 15:33 -0700, CSN wrote: >> select * from table1 >> where last_error is null >> or extract(epoch from now()-last_error) > 86400; > I don't know whether the planner would recognise that it could use an > index on that condition. The "is null" isn't in

Re: [GENERAL] selecting rows older than X, ensuring index is used

2005-08-20 Thread Oliver Elphick
On Sat, 2005-08-20 at 15:33 -0700, CSN wrote: > Hi, > > I want to select records that haven't had an error > (logged to last_error) in the last 24 hours. My query > is: > > select * from table1 > where last_error is null > or extract(epoch from now()-last_error) > 86400; I don't know whether the

[GENERAL] selecting rows older than X, ensuring index is used

2005-08-20 Thread CSN
Hi, I want to select records that haven't had an error (logged to last_error) in the last 24 hours. My query is: select * from table1 where last_error is null or extract(epoch from now()-last_error) > 86400; I've created an index on last_error (timestamp with time zone - can be NULL), then used