3 ms·
One trick with counts is that you very rarely need a perfectly accurate count for that exact moment in time; doing an explain on an appropriate 'SELECT' and cap
by falcolas 10y ago
One trick with counts is that you very rarely need a perfectly accurate count for that exact moment in time; doing an explain on an appropriate 'SELECT' and capturing the estimated number of rows returned by that is usually good enough in 98% of the cases.
When you do need an accurate count, phrasing the query so the results can be pulled exclusively from the table index is also usually good enough.
- ishi 10y agoNever thought of using EXPLAIN to get an estimated count... nice trick!