I'm currently using django-voting in my website. But it turns out, when number of voting.Vote.objects.counts() comes to 10, 000, this query is slow (1.03 seconds) and appears in mysql-slow.log
# Query_time: 1.031839 Lock_time: 0.000069 Rows_sent: 1 Rows_examined: 72754
SET timestamp=1363621528;
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;
I'm wondering if there is a better way to achieve this?