James Tu wrote:
What does MySQL do internally when you perform a LEFT JOIN?
You can read about it here:
<URL: http://dev.mysql.com/doc/mysql/en/left-join-optimization.html >
If you need more details, you could read the source...
Let's say you have two tables:
Table A has 1,000,000 rows
Table B has 5,000 rows
When you perform the following LEFT JOIN:
Select A.*, B.*
FROM A, B
WHERE
A.lastname = 'doe' AND A.id <http://A.id> = B.id <http://B.id>
eh... that's not a LEFT JOIN...?
What does MySQL do internally?
Does it first create some sort of CROSS JOIN with the two tables (resulting
in a 5,000,000,000 row table)
and then finding the matching rows based on the WHERE clause?
If there is no index on A.lastname and B.id, probably yes...
Use the EXPLAIN SELECT command to see how MySQL plan to solve the query.
<URL: http://dev.mysql.com/doc/mysql/en/explain.html >
--
Roger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]