[Answer]-How should I resolve this slow voting query in mysql-slow.log?

1👍

You should take a look on that table votes through mysql client, and execute explain select:

EXPLAIN SELECT (COALESCE(SUM(vote), 0)) AS `score`, (COALESCE(COUNT(vote), 0)) AS `num_votes`   FROM `votes` WHERE (`votes`.`object_id` = 10136  AND `votes`.`content_type_id` = 48 ) LIMIT 1;   

then check if columns ‘vote’ is indexed during this query, if not – you should add new index on ‘vote’ column.

Leave a comment