关于Exists的效率问题
论坛里有个帖子,原贴地址:
http://community.csdn.net/Expert/topic/4192/4192302.xml?temp=.9121973
帖子内容:
查询订购的产品至少包含了订单3号中所订购产品的订单。
Select distinct order_no from sale_item a
Where order_no<>'3'and not exists (
Select * from sale_item b where order_no ='3' and not exists
(select * from sale_item c where c.order_no=a.order_no and c.prod_id=b.prod_id))
我想讨论的是,当sale_item中的数据量大于10000时,查询的时间非常长,运行了20分钟都还没有完。这种效率在实际应用中肯定是不行的,有没有提高效率的方法呢?