MySQL Forums
Forum List  »  Performance

Re: Index usage (subquery with MAX)
Posted by: KimSeong Loh
Date: May 03, 2005 06:36PM

Looks right to me.

The 1st query reads all the rows once to complete the work.

The 2nd query needs to read all the rows as well, and for each row it will need to read the table again to find all the matching `name` to get the max of `time`. It uses the index on `name`. Estimated to read about 10% of the table for each of the 5000 rows, so in total you need to evaluate about 5000 multiply by 504 set of data.
DEPENDENT SUBQUERY is bad because it needs to be evaluated once for each of the row in the outer query.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Index usage (subquery with MAX)
1689
May 03, 2005 06:36PM


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.