Re: Close to a million records & query too slow
Rick, thanks for your response and help, really appreciated.
The query :
select a.artistId,
a.name,
( SELECT count(*) FROM play
WHERE dateAndTime >= ?
AND dateAndTime < DATE_ADD(?, INTERVAL 1 DAY)
AND songId = s.songId
) as plays
from artist a,
song s
where (s.artistId = a.artistId)
and (a.isLocal = ?)
order by plays desc;
does not yield the same results as the original. It's supposed to add up all the plays for the artist on the date range. The good news is, the index "INDEX(songId, dateAndTime);" does work fantastically. It has reduced the response time from 9.4 sec to 0.06 which is super. From your advice I've had to alter the original query to this:
from charts.play play, charts.artist artist,
charts.song song
where (play.songId = song.songId)
and (song.artistId = artist.artistId)
and dateAndTime >= ?
AND dateAndTime < DATE_ADD(?, INTERVAL 1 DAY)
and (artist.isLocal = ?)
group by artist.artistId
order by plays desc;
This, with the index you suggested seems to improve the performance dramatically and it solves my problem.
Thanks Rick, your expertise in this field is astounding. Thanks for sharing it with us.
--
Sabelo
Subject
Views
Written By
Posted
6615
March 03, 2010 01:49PM
2631
March 04, 2010 10:09PM
2395
March 08, 2010 03:36PM
2045
March 08, 2010 04:12PM
2484
March 09, 2010 09:20PM
Re: Close to a million records & query too slow
2073
March 11, 2010 01:47AM
Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.