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(*)
If you have InnoDB, count(*) and any other aggregate function will do a table scan. I see a few solutions here:
update table set count = count + 1. Pros: fast updates, integrity (you may want to use a lock though in case several clients can alter the same record). Cons: you couple a bit of business logic and storage.