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
1724
March 20, 2015 07:00AM
776
March 20, 2015 07:55AM
750
March 20, 2015 08:00AM
732
March 22, 2015 04:11PM
712
March 23, 2015 12:46AM
Re: Slow COUNT + GROUP BY
1089
March 23, 2015 02:45AM
980
March 23, 2015 04:30AM
893
March 23, 2015 06:04AM
755
March 23, 2015 08:13AM
767
March 24, 2015 02:02AM
755
March 24, 2015 02:51AM
779
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.