在SQL 2008中使用大表进行有效的分页

编程入门 行业动态 更新时间:2024-10-14 08:26:54
本文介绍了在SQL 2008中使用大表进行有效的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

用于具有> 1,000,000行并且可能还有更多行的表!

for tables with > 1,000,000 rows and possibly many many more !

我自己没有进行任何基准测试,所以想征询专家的意见.

haven't done any benchmarking myself so wanted to get the experts opinion.

看了row_number()上的一些文章,但似乎对性能有影响

Looked at some articles on row_number() but it seems to have performance implications

还有哪些其他选择/替代方案?

What are the other choices/alternatives ?

推荐答案

我们使用row_number()可以产生很大的效果,并且实际上没有任何性能问题.分页查询的基本结构如下:

We use row_number() to great effect and there hasn't really been any performance issues with it. The basic structure of our paginated queries looks like this:

WITH result_set AS ( SELECT ROW_NUMBER() OVER (ORDER BY <ordering>) AS [row_number], x, y, z FROM table WHERE <search-clauses> ) SELECT * FROM result_set WHERE [row_number] BETWEEN a AND b

对于具有1,000,000行以上的表,它对我们来说很好用.

It works fine for us on tables with > 1,000,000 rows.

更多推荐

在SQL 2008中使用大表进行有效的分页

本文发布于:2023-10-26 17:38:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530863.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分页   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!