Bluehost.com Web Hosting $6.95

Slow query

This is a discussion on Slow query within the MySQL Database forums, part of the Database Forums category; Hi all, I have a query that counts lines with certain properties, grouped by day. But the time is stored ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-03-2006
Bernhard Kornberger
 
Posts: n/a
Default Slow query

Hi all,

I have a query that counts lines with certain properties, grouped by
day. But the time is stored in seconds, therefore I do it as follows:

EXPLAIN SELECT
received_time as raw_date,
DATE_FORMAT(FROM_UNIXTIME(received_time), '%d. %M %Y') AS format_date,
sum(case when server_state=5 and outcome=1 then 1 else 0 end) as
wu_success,
sum(cpu_time/3600) as cpu_hours,
sum(case when server_state=5 and outcome!=1 and outcome!=4 then 1 else 0
end) as wu_other
FROM result
WHERE received_time>1162277941
GROUP BY format_date DESC
ORDER BY raw_date DESC:

*** row 1 ***
table: result
type: range
possible_keys: idx_received_time
key: idx_received_time
key_len: 4
ref: NULL
rows: 110388
Extra: Using where; Using temporary; Using filesort

That works but the query takes several minutes to complete. Is it
possible to speed it up? The table result holds about 250 000 lines
and it has an index on the received_time column but I'm not sure if
the index really helps in that case.



Thx. Best
Bernahrd
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:11 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0