MySQL Forums
Forum List  »  Optimizer & Parser

Re: Query with GROUP BY not using Index
Posted by: Øystein Grøvlen
Date: August 29, 2012 01:28AM

Hi,

A temporary table is involved in the original query, too, since the result of the sub-query will be stored in a temporary table. However, in that case MySQL is able to detect that it can use an index efficiently for the GROUP BY, and the temporary table is smaller since the aggregation has already been performed. For the simplified query, the aggregation is done on the temporary table. Hence, this temporary will be much bigger.

I notice that I made a mistake in the query that I proposed. It should of course be "ORDER BY MIN(t1.date)" (or just "ORDER BY 2"). I do not know whether that would make a difference.

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

Options: ReplyQuote


Subject
Views
Written By
Posted
2950
August 14, 2012 01:06PM
Re: Query with GROUP BY not using Index
1806
August 29, 2012 01:28AM


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.