MySQL Slow Query Optimization Tips
Slow Query Example
SELECT
widget_id
, widget_name
, COUNT(DISTINCT type) AS num_types
FROM widget
GROUP BY type
ORDER BY num_types DESC
With lots (>100K) of rows, this query will get slow because it orders on an aggregate COUNT DISTINCT function. Remove the ORDER BY to make this fast again.
Categories: MySQL
Recent Comments