比如
select * from Outcome_history where eventId not in (select id from Event_history)
我执行得到结果时间为 0.267s
如果按照常规数据库优化 必须将not in换成not exist
select * from Outcome_history where not EXISTS (select id from Event_history where Event_history.id=Outcome_history.eventId)
0.266s (有时会是0.297,这是第1次执行的时间,后来的因为缓存就快了)
再换
select * from Outcome_history a where not EXISTS (select b.id from Event_history b where b.id=a.eventId)
0.281s (为什么mysql加上别名会慢上很多 ,很奇特的现象 ?? 这2个表都很大,第1表17万,第2条10万条)