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