MySQL Forums
Forum List  »  Performance

Re: Slow COUNT + GROUP BY
Posted by: Jeremy Smyth
Date: March 20, 2015 07:55AM

Unless your "day" column is your primary key, that FORCE INDEX is going to force a full table scan every time. Get rid of it, and index the "day" column.

Index (day,uid) if uid isn't the PK in that table.

Also, consider rephrasing the inner query SELECT COUNT(DISTINCT uid) FROM ... so you can get rid of the outer query and do it all in one logical pass and make the optimizer's job a little easier.

Options: ReplyQuote


Subject
Views
Written By
Posted
1750
March 20, 2015 07:00AM
Re: Slow COUNT + GROUP BY
787
March 20, 2015 07:55AM
766
March 20, 2015 08:00AM
742
March 22, 2015 04:11PM
726
March 23, 2015 12:46AM
1102
March 23, 2015 02:45AM
1005
March 23, 2015 04:30AM
906
March 23, 2015 06:04AM
772
March 23, 2015 08:13AM
779
March 24, 2015 02:02AM
768
March 24, 2015 02:51AM
790
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.