+1  A: 

Personally, I would try to break the query up into multiple queries. Mostly I would recommend removing the Actor and Genre Joins so that you can get rid of all those group_concat functions. Then do separate queries to pull this data out. Not sure if it would speed things up, but it's probably worth a shot.

Kibbee
A: 

You've basically done a Cartesian product between genres, actors, directors, movie_ratings and episodes. That's why you have to use DISTINCT inside your GROUP_CONCAT(), because the pre-grouped result set has a number of rows equal to the product of the number of matching rows in each related table.

Note that this query wouldn't work at all in SQL, except that you're using MySQL which is permissive about the single-value rule.

Like @Kibbee, I usually recommend to run separate queries in cases like this. It's not always better to run a single query. Try breaking up the query and doing some profiling to be sure.

PS: What? No _directors table? So you can't represent a move with more than one director? :-)

Bill Karwin
Yah I was just lazy. :PIs there anything wrong with using GROUP_CONCAT?
Yegor
There's nothing wrong with using GROUP_CONCAT when you need it, but in your case you're just going to explode the list anyway, so why bother?
Bill Karwin
Figured I'd run elss queries, whcih is good. I guess I replace them with 2 other queries and see what happens.
Yegor