MySQL Forums
Forum List  »  Optimizer & Parser

Re: Make this faster?
Posted by: Björn Steinbrink
Date: January 04, 2007 03:34PM

Adding (redundant) columns for year and month plus an index on those columns, ie. (year, month) should allow MySQL to utilize that index for the group by operation. You should also drop the order by part in that query. Because of the group by, only the year and month parts of it are actually meaningful and MySQL will order by those anyway, because group by includes ordering and ordering by a different column always forces a file sort.

That said, I'm not sure if COUNT(files.md5_key) is really what you want. IIRC, because of the join, that should give you the number of row in the files table times the number of matching rows in the filesystem table for each file. I'd expect to see COUNT(DISTINCT files.md5_key) there instead.

Options: Reply• Quote


Subject
Views
Written By
Posted
4219
January 04, 2007 07:38AM
2493
January 04, 2007 10:21AM
2473
January 04, 2007 11:51AM
Re: Make this faster?
2588
January 04, 2007 03:34PM
2575
January 05, 2007 02:40AM
2501
January 05, 2007 05:07AM
2512
January 05, 2007 06:55AM
2629
January 05, 2007 08:31AM
2486
January 05, 2007 08:33AM
2770
January 05, 2007 08:45AM
2505
January 05, 2007 08:31AM
2573
January 05, 2007 08:45AM
2608
January 05, 2007 03:11PM
2519
January 08, 2007 02:44AM
2465
January 08, 2007 04:28AM
2534
January 08, 2007 04:41AM


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.