简单测试分页,省得总是忘记
2010-07-25 15:03 迷 阅读(170) 评论(0) 编辑 收藏 举报开销:30% 特点:两次排序38%*2,一次嵌套循环1%,两次聚集索引扫描11%*2
SELECT TOP 10 * FROM dbo.T_AUT_OrganizationInfo
WHERE F_ID > (SELECT Max(F_ID) FROM (SELECT TOP 30 F_ID FROM dbo.T_AUT_OrganizationInfo ORDER BY F_ID) AS TempTable)
ORDER BY F_ID;
开销:35% 特点:两次排序33%*2,一次合并链接16%,两次聚集索引扫描9%*2
SELECT TOP 10 * FROM dbo.T_AUT_OrganizationInfo
WHERE F_ID NOT IN (SELECT TOP 30 F_ID FROM dbo.T_AUT_OrganizationInfo ORDER BY F_ID)
ORDER BY F_ID;
开销:35% 特点:两次排序33%*2,一次合并链接16%,两次聚集索引扫描9%*2
SELECT TOP 10 * FROM dbo.T_AUT_OrganizationInfo A
WHERE NOT EXISTS (
SELECT * FROM (
SELECT TOP 30 F_ID FROM dbo.T_AUT_OrganizationInfo ORDER BY F_ID
) AS B WHERE A.F_ID=B.F_ID
)
ORDER BY F_ID;
还是 Max 快,Not In 和 Exists 居然是没有区别的...记得曾经某文章分析好像他们某个是内表较大快,一个是外表较大快,有时间再测了。