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: ReplyQuote


Subject
Views
Written By
Posted
3822
January 04, 2007 07:38AM
2300
January 04, 2007 10:21AM
2253
January 04, 2007 11:51AM
Re: Make this faster?
2354
January 04, 2007 03:34PM
2381
January 05, 2007 02:40AM
2289
January 05, 2007 05:07AM
2281
January 05, 2007 06:55AM
2313
January 05, 2007 08:31AM
2303
January 05, 2007 08:33AM
2525
January 05, 2007 08:45AM
2269
January 05, 2007 08:31AM
2348
January 05, 2007 08:45AM
2387
January 05, 2007 03:11PM
2324
January 08, 2007 02:44AM
2226
January 08, 2007 04:28AM
2311
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.