Working on subquery optimizations, got an idea how to speed up join execution a little. Read on.
The idea
Consider a query:
select * from t1, t2, t3 where t3.key=t1.col1 and t2.key=t1.col2
Suppose the join order is t1, t2, t3, i.e. the EXPLAIN is like
+-------+------+---------------+------+---------+--------------+-.. | table | type | possible_keys | key | key_len | ref | +-------+------+---------------+------+---------+--------------+-.. | t1 | ALL | NULL | NULL | NULL | NULL | | t2 | ref | key | key | 5 | test.t1.col1 | | t3 | ref | key | key | 5 | test.t1.col2 | +-------+------+---------------+------+---------+--------------+-..
The important property is that access to t3 is independent of access to t2. MySQL's nested loops join algorithm will run this as in this swimlane diagram:
Here we assume that
- …