Following query taking too long to execute. How to optimize it
问题 I use the following query to get years and the number of movies released in that year which(referring to a movie) has a female actor. It executes successfully, but it is taking 4 minutes to execute. How do I get results in less time? Also, my disk use goes to more than 70% during this execution. SELECT m.year, COUNT(m.id) FROM movies m JOIN roles r ON m.id=r.movie_id JOIN actors a ON r.actor_id=a.id WHERE a.gender='F' GROUP BY m.year; 回答1: I think you can use EXISTS instead of JOIN. SELECT m