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