MYSQL execution time comparison(MYSQL 运行时间比较)-subselect vs select from 2 table

table t: device | lot |

table o: device

 

1. subselect==> 运行时间(execution time) = 6000 ms

select distinct device from t where lot = 'x'
and (device in (select distinct device from o where device like 'y%'));

 

 2. select from 2 table==>运行时间(execution time) = 357ms

select distinct t.device from test_out_realtime t, opn_pbi_lot_view o where
t.lot='1548353' and o.device like '8660AU46%' and t.device=o.device;

由此可见:MYSQL subselect 运行速度很慢,所以能避免就要避免。大部分情况下,都可以通过select from 2 table 解决

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章