title: MySQL Slow on join. Any way to speed up
body: <p>I have 2 tables. 1 is music and 2 is listenTrack. listenTrack tracks the unique plays of each song. I am trying to get results for popular songs of the month. I'm getting my results but they are just taking too long. Below is my tables and query</p>
  
  <p>430,000 rows</p>
  
  <pre><code>CREATE TABLE `listentrack` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `sessionId` varchar(50) NOT NULL,
      `url` varchar(50) NOT NULL,
      `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      `ip` varchar(150) NOT NULL,
      `user_id` int(11) DEFAULT NULL,
       PRIMARY KEY (`id`)
  ) ENGINE=MyISAM AUTO_INCREMENT=731306 DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>12500 rows</p>
  
  <pre><code>CREATE TABLE `music` (
     `music_id` int(11) NOT NULL AUTO_INCREMENT,
     `user_id` int(11) NOT NULL,
     `title` varchar(50) DEFAULT NULL,
     `artist` varchar(50) DEFAULT NULL,
     `description` varchar(255) DEFAULT NULL,
     `genre` int(4) DEFAULT NULL,
     `file` varchar(255) NOT NULL,
     `url` varchar(50) NOT NULL,
     `allow_download` int(2) NOT NULL DEFAULT '1',
     `plays` bigint(20) NOT NULL,
     `downloads` bigint(20) NOT NULL,
     `faved` bigint(20) NOT NULL,
     `dateadded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
     PRIMARY KEY (`music_id`)
  ) ENGINE=MyISAM AUTO_INCREMENT=15146 DEFAULT CHARSET=utf8
  
  
  SELECT COUNT(listenTrack.url) AS total, listenTrack.url 
  FROM listenTrack
  LEFT JOIN music ON music.url = listenTrack.url
  WHERE DATEDIFF(DATE(date_created),'2009-08-15') = 0
  GROUP BY listenTrack.url
  ORDER BY total DESC
  LIMIT 0,10
  </code></pre>
  
  <p>this query isn't very complex and the rows aren't too large, i don't think.</p>
  
  <p>Is there any way to speed this up? Or can you suggest a better solution? This is going to be a cron job at the beggining of every month but I would also like to do by the day results as well.</p>
  
  <p>Oh btw i am running this locally, over 4 min to run, but on prod it takes about 45 secs</p>