MySQL Forums
Forum List  »  Performance

Re: Slow COUNT + GROUP BY
Posted by: Øystein Grøvlen
Date: March 23, 2015 02:45AM

Hi,

AFAICT, your query is equivalent to the following query:

SELECT COUNT(DISTINCT uids) FROM unique_playing
WHERE day BETWEEN "2013-03-01 00:00:00.000" AND "2015-03-18 00:00:00.000";

FORCE INDEX(PRIMARY) should normally not be beneficial unless most of your records are within the given the date period. I suspect the problem is that the index on day is not used for some reason. What type is your day column? SHOW CREATE TABLE for the table and EXPLAIN output for the query (without FORCE INDEX) should probably tell us more.

What storage engine are you using, InnoDB or MyISAM? What version of MySQL?

Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway

Options: ReplyQuote


Subject
Views
Written By
Posted
1900
March 20, 2015 07:00AM
866
March 20, 2015 07:55AM
839
March 20, 2015 08:00AM
882
March 22, 2015 04:11PM
795
March 23, 2015 12:46AM
Re: Slow COUNT + GROUP BY
1173
March 23, 2015 02:45AM
1133
March 23, 2015 04:30AM
991
March 23, 2015 06:04AM
860
March 23, 2015 08:13AM
857
March 24, 2015 02:02AM
853
March 24, 2015 02:51AM
868
March 24, 2015 03:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.