How to speed up select count(*)
with group by
?
It\'s too slow and is used very frequently.
I have a big trouble using select count(*)
I see that a few individuals have asked what engine you were using for the query. I would highly recommend you use MyISAM for the following reasions:
InnoDB - @Sorin Mocanu properly identified that you will do a full table scan regardless of indexes.
MyISAM - always keeps the current row count handy.
Lastly, as @justin stated, make sure you have the proper covering index:
CREATE INDEX ix_temp ON relations (relation_title, object_title);