MySQL Forums
Forum List  »  Optimizer & Parser

Re: JOIN with GROUP BY, without PRIMARY KEY
Posted by: KimSeong Loh
Date: May 17, 2006 09:44PM

Is B.gr your primary key?

MySQL optimiser choose the 1st option because there is only 1 row to read from table B, due to the where B.gr = 1, I expect this is the primary key in table B, so this is very efficient for the join.

The 2nd option with the force index, reads table A first, this will allow it to eliminate the temporary and sorting, but may need to read more rows in the join, actually all the rows in table A, it read from the index in this case, the whole index tree.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: JOIN with GROUP BY, without PRIMARY KEY
2197
May 17, 2006 09:44PM


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.