Monday, April 23, 2012

MySQL group-by very slow

I have the folowwing SQL query



SELECT CustomerID FROM sales WHERE `Date` <= '2012-01-01' GROUP BY CustomerID


The query is executed over 11400000 rows and runs very slow. It takes over 3 minutes to execute. If I remove the group-by part, this runs below 1 second. Why is that?



MySQL Server version is '5.0.21-community-nt'





No comments:

Post a Comment