在 SQL Server 2000 中对大量数据进行分页的最有效方法是什么?
如果我有一个包含大量信息的查询(比如几个视图,每个视图都访问几个表,其中许多表有数万行),并且我只需要从中获取 10 条记录即可显示到用户,在性能方面,检索这些记录同时仍支持 SQL Server 2000 的最佳方法是什么?一旦我可以使用 SQL Server 2005,ROW_NUMBER
似乎是显而易见的选择(如果我错了,请纠正我),但是 2000 年该怎么办?
If I have a query with a lot of information (something like a couple of views that each hit a handful of tables, with many tables having tens of thousands of rows), and I just need to get 10 records from it to display to the user, what's the best way, performance-wise, to retrieve those records while still supporting SQL Server 2000? Once I can use SQL Server 2005, ROW_NUMBER
seems like the obvious choice (correct me if I'm wrong), but what to do in 2000?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Greg Hamilton 有一篇文章 使用
SET ROWCOUNT
和 < code>SELECT 到变量中以避免引用不需要的行,从而获得一些非常引人注目的性能结果。但是,MSDN 说但接着又说
表明在这种情况下确实没问题(对吗?)
Greg 最终得到了这样的结果:
此方法假设您有一个唯一的 ID 来排序,我不认为您可以在排序时按原样使用此方法,比如说,一个非唯一的 DateTime 列。
Greg Hamilton has an article which uses
SET ROWCOUNT
andSELECT
ing into a variable to avoid having to reference rows that aren't needed, with some pretty compelling performance results. However, MSDN saysBut then it goes on to say
Indicating that it's really okay in this instance (right?)
Greg ends up with this:
This method assumes that you have a unique ID to order by, I don't think that you can use this method as-is when sorting on, say, a non-unique DateTime column.