Re: JOIN with GROUP BY, without PRIMARY KEY
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.
Subject
Views
Written By
Posted
6678
May 12, 2006 10:57AM
2432
May 14, 2006 06:58PM
2451
May 17, 2006 10:30AM
Re: JOIN with GROUP BY, without PRIMARY KEY
2238
May 17, 2006 09:44PM
2298
May 23, 2006 09:39AM
3695
May 25, 2006 12:31PM
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.