Re: [PERFORM] Too slow querying a table of 15 million records

2005-06-28 Thread Tom Lane
PFC <[EMAIL PROTECTED]> writes: > 1. Use CURRENT_TIMESTAMP (which is considered a constant by the > planner) > instead of now() Oh? regards, tom lane ---(end of broadcast)--- TIP 2: you can get off all lists at once

Re: [PERFORM] Too slow querying a table of 15 million records

2005-06-28 Thread PFC
database=> explain select date_trunc('hour', time),count(*) as total from test where p1=53 and time > now() - interval '24 hours' group by date_trunc order by date_trunc ; 1. Use CURRENT_TIMESTAMP (which is considered a constant by the planner) instead of now() 2. Create a multicolumn ind

Re: [PERFORM] Too slow querying a table of 15 million records

2005-06-28 Thread Christopher Kings-Lynne
database=> explain select date_trunc('hour', time),count(*) as total from test where p1=53 and time > now() - interval '24 hours' group by date_trunc order by date_trunc ; Try going: time > '2005-06-28 15:34:00' ie. put in the time 24 hours ago as a literal constant. Chris -

Re: [PERFORM] Too slow querying a table of 15 million records

2005-06-28 Thread John A Meinel
Tobias Brox wrote: [EMAIL PROTECTED] - Tue at 08:33:58PM +0200] I use FreeBSD 4.11 with PostGreSQL 7.3.8. (...) database=> explain select date_trunc('hour', time),count(*) as total from test where p1=53 and time > now() - interval '24 hours' group by date_trunc order by date_trunc ;

Re: [PERFORM] Too slow querying a table of 15 million records

2005-06-27 Thread Tobias Brox
[EMAIL PROTECTED] - Tue at 08:33:58PM +0200] > I use FreeBSD 4.11 with PostGreSQL 7.3.8. (...) > database=> explain select date_trunc('hour', time),count(*) as total from > test where p1=53 and time > now() - interval '24 hours' group by > date_trunc order by date_trunc ; I haven't looked through