mysql 之 explain

刚和同事讨论一个问题,关于orm 不知不觉,又谈到了 mysql之表关联

他的意思是尽量少用表关联,而使用多次查询的方式。

如果使用表关联,如何达到最佳效果呢?

使用mysql的 explain 函数可以 让mysql  得到解析

加上map1.uid 是索引 而user.id 也是其主键的话。

explain select * from map1 left join user on map1.uid = `user`.id;#101.297s

explain select * from map1 ,user where map1.uid = `user`.id;  #87.422s

explain select * from map1 inner join user on map1.uid = `user`.id;#84.063s

你可能感兴趣的:(EXPLAIN)