In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `rec` ADD INDEX `rec_idx_toamovieid` (`toAMovieID`);
ALTER TABLE `userFavorites` ADD INDEX `userfavorites_idx_userid_movieid` (`userid`,`movieid`);
SELECT
rec.toMovieID,
sum(rec.score)
FROM
rec
WHERE
EXISTS (
SELECT
1
FROM
userFavorites AS ufv
WHERE
(
ufv.userid = 29
)
AND (
rec.movieID = ufv.movieid
)
)
GROUP BY
rec.toAMovieID
ORDER BY
rec.score DESC LIMIT 10