mysql inner join性能

select count(1) from (
select login_id,id from PlatformPassPort where login_id like 'ab%'
) t1 inner join
pp_PlatformAccount t2 on t1.id = t2.passportId

select count(1) from PlatformPassPort t1 inner join
pp_PlatformAccount t2 on t1.id = t2.passportId
 where login_id like 'ab%'

本来以为inner join先执行的话可能会导致速度变慢(测试的是160w的数据量,基本是表表的全连接) ,但是发现结果2者时间差不多,可能mysql做了优化。100条以内的数据量应该感觉不到时间。所以,我的结论是:有限条目的查询条件(尤其是单表的查询)
可以放心使用inner join -- 即使数据上百万。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章