语句1:
 select tb1.* from tb1 left join tb2 on tb1.ids=tb2.ids left join tb3 on tb1.ids=tb3.ids
 此语句在调用转化前:
                  TOP_JOIN_LIST
                      |
                  TABLE_LIST(nested_last)
                  nested_join
                  join_list
                  /       \    
                 /         tb3 on (tb1.ids=tb3.ids) 
        TABLE_LIST(nested_last)
        nested_join
        join_list
        /     \
       tb1   tb2 on (tb1.ids=tb2.ids)
       在simplify_joins()中的代码
        else if (nested_join && !table->join_cond())
        {
            因为两个nested_last的都没有join_cond,所以nested_last最终都会被移除,上拉到最上层:
            top_join_list
            /    |      \
          tb1   tb2(on..)   tb3(on..)
        }

 语句2:
 select tb1.* from tb1 left join (tb2,tb3) on tb1.ids=tb2.ids
 在此语句调用前结构:
            TOP_JOIN_LIST
                |
          TABLE_LIST(nested_last)
          join_list
         /      \
        tb1     TABLE_LIST(nested_join) on (tb1.ids=tb2.ids)
                   join_list
                  /      \
                tb2        tb3
同样在simplify_joins()代码中
else if (nested_join && !table->join_cond())
{
nested_last因为没有join_cond,所以tb1与nested_join都会被上拉到TOP_JOIN_LIST中,tb1.embedding为NULL,
nested_join的join_cond不能转移到WHERE 中,且也不能转为内联接,所以tb2,tb3并不能像上一条语句一样直接上拉到TOP_JOIN_LIST,
tb2,tb3位于嵌套中,估计表的记录数时只能是全表扫描
}

09-22 00:35