You can always use EXPLAIN or EXPLAIN EXTENDED to find out what MySql does with the query.
You can also write your request a little differently, have you tried the following?
SELECT s.*, sm.url AS media_url FROM shows AS s INNER JOIN show_medias AS sm ON s.id = SM.show_id WHERE `s`.`id` IN ( SELECT DISTINCT st.show_id FROM show_time_schedules AS sts LEFT JOIN show_times AS st ON st.id = sts.show_time_id WHERE sts.schedule_date BETWEEN CAST('2012-01-10' AS date) AND CAST('2012-01-14' AS date) ) AND `s`.`is_active` = 1 AND sm.is_primary = 1 ORDER BY s.name asc
It would be interesting to see what the effect of this is. I would expect this to be faster, since at the moment I think MySql will run an internal query 1 for each show you show (so that one query is executed many times. The connection should be more efficient.)
Replace INNER JOIN with LEFT JOIN if you want all shows that do not have a line in show_medias.
EDIT:
In the near future I will look at your EXPLAIN EXTENDED, I also wonder if you want to try the following: it deletes all subqueries:
SELECT DISTINCT s.*, sm.url AS media_url FROM shows AS s INNER JOIN show_medias AS sm ON s.id = SM.show_id INNER JOIN show_times AS st ON (s.id = st.show_id) RIGHT JOIN show_time_schedules AS sts ON (st.id = sts.show_time_id) WHERE `s`.`is_active` = 1 AND sm.is_primary = 1 AND sts.schedule_date BETWEEN CAST('2012-01-10' AS date) AND CAST('2012-01-14' AS date) ORDER BY s.name asc
(It would also be useful to see EXPLAIN EXTENDED on them - you can add it in the comments for this).
Further EDIT:
On your EXPLAIN EXTENDED (a good start on how to read this here )
USING FILESORT and USING TIME are both key indicators. Hopefully the second query that I recommend should remove any TEMPORARY tables (in the subquery). Try leaving ORDER BY off to see if this matters (and we can add this to the conclusions so far :-)
I also see that the query is potentially missing in many indexes; all your id columns are the first candidates for index matches (with the usual index warning ). I also tried adding these indexes and then running EXPLAIN EXTENDED again to find out what the difference is now (EDIT, as we already know from your comment above!)
source share