惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
P
Privacy International News Feed
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 叶小钗
F
Fortinet All Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 最新话题
AWS News Blog
AWS News Blog
Engineering at Meta
Engineering at Meta
Attack and Defense Labs
Attack and Defense Labs
Recent Announcements
Recent Announcements
Recent Commits to openclaw:main
Recent Commits to openclaw:main
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
IT之家
IT之家
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
J
Java Code Geeks
M
MIT News - Artificial intelligence
Cisco Talos Blog
Cisco Talos Blog
V2EX - 技术
V2EX - 技术
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
G
Google Developers Blog
W
WeLiveSecurity
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
T
Tailwind CSS Blog
V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Secure Thoughts
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
Blog — PlanetScale
Blog — PlanetScale
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed

博客园 - yi

Rabbitmq的使用及Web监控工具使用 Fiddler的配置 轻松实现SQL Server与Access、Excel数据表间的导入导出 Sql server性能优化白皮书 索引的优化脚本 查找当前的登录用户 usp_who5脚本,查找当前的进程 linq to sql的性能和reader相比只是差一点点吗 锁与索引 一个数据访问层的小工具 转:对XML插入操作 - yi - 博客园 查看当前的连接和锁 关注商业价值 应用程序优化 关于异常处理的一点看法 骂的人多了,也成了真理 样式小记 - yi - 博客园 重命名你的数据库 不浪费自己的时间,同时也不浪费别人的时间 - yi - 博客园
对数据的分页再一次思考
yi · 2010-05-10 · via 博客园 - yi

  使用Row_Number()和CTE就非常容易进行数据分面了,在这里不再描述,请查找博客园的相关随笔.

  在这里所说的是返回数据行数,大家可以再查询一次,这无疑是对IO再进行一次消耗,我们应该如何完成这个功能呢。废话我也不说了,给出代码,然后你们再自己测试一下

DECLARE @startRow INT ; SET @startrow = 20;

WITH cols
AS
(
    SELECT name,
        ROW_NUMBER() OVER(ORDER BY name) AS seq,
        ROW_NUMBER() OVER(ORDER BY name desc) AS totalRows
    FROM table

)
SELECT name, totalRows + seq -1 as TotRows
FROM cols
WHERE seq BETWEEN @startRow AND @startRow + 19
ORDER BY seq

  从这个来看,无疑增加了CPU的使用,但对于IO的使用降到了最低,从我的经验来看,IO的问题远大于CPU的问题,特别是对于复杂的查询。