参考文章:SQL SERVER性能优化综述(很好的总结,不要错过哦)
数据库:系统数据库pubs
IN的相关子查询用EXISTS代替,比如:
SELECT PUB_NAME FROM PUBLISHERS
WHERE PUB_ID IN (
SELECT PUB_ID
FROM TITLES
WHERE TYPE = 'BUSINESS')
改进如下:
SELECT PUB_NAME FROM PUBLISHERS
WHERE EXISTS (
SELECT 1
FROM TITLES
WHERE TYPE = 'BUSINESS' AND PUB_ID= PUBLISHERS.PUB_ID)