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 解決

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