sql千万级数据分页效率分析与方法
Jun 07, 2016 pm 05:48 PMsql千万级数据效率分析与方法
top 100 * from (select top 500 * from T1 order by id asc) a order by id desc
先asc取前500条 再倒着取(desc)这个结果的100条...
MSSQL在我这里测试通过
这个ID字段如果是默认的升序序列 也是主键列 那下面这句就能实现了
select * from t1 where id between 400 and 500
我就知道三种方法 having in between and 和 >= and 测试过 between and 的效率应该是3者最高的
首先: id>400 and id
id>=401 and id
最好的方法:用FIRST_ROWS(n)优化器提示:用它的目的是提高SQL语句的响应时间,快速的先返回 n 行
另外between and 的效率最高
select /* FIRST_ROWS (100) */
id, username from t1
where id between 401 and 500
最后总结
在查询点来看,用between...and比取“”号的效率要高
select a.*
from table1 a
where rownum between 10000001 and 10000101

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Asynchronous processing method of Select Channels Go concurrent programming using golang

How to hide the select element in jquery

How to implement change event binding of select elements in jQuery

What is the reason why Linux uses select?

You can't specify target table 'table_name' for update in FROM clause - How to solve MySQL error: Unable to update target table in FROM clause

How to use the select syntax of mysql

What does 500internal server error mean?

Implement Select Channels Go concurrent programming performance optimization through golang
