如
我要查询Sendorder表中的冗余数据(没有和reg_person或worksite相连的数据)
sql="selectSendorder.id,Sendorder.reads,Sendorder.addtimefromSendorderwhereSendorder.person_idnotin(selectuser_idfromreg_person)orSendorder.worksite_idnotin(selectidfromworksite)orderbySendorder.addtimedesc"
程序执行时间:40109.38毫秒
sql="selectSendorder.id,Sendorder.reads,Sendorder.addtimefromSendorderwherenotEXISTS(SELECTidFROMreg_personwherereg_person.user_id=Sendorder.person_id)ornotEXISTS(SELECTidFROMworksitewhereworksite.id=Sendorder.worksite_id)orderbySendorder.addtimedesc"
程序执行时间:8531.25毫秒
很明显使用notEXISTS效率高多了