Home Database Mysql Tutorial sql千万级数据分页效率分析与方法

sql千万级数据分页效率分析与方法

Jun 07, 2016 pm 05:48 PM
500 and from select

sql千万级数据效率分析与方法

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

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Asynchronous processing method of Select Channels Go concurrent programming using golang Asynchronous processing method of Select Channels Go concurrent programming using golang Sep 28, 2023 pm 05:27 PM

Asynchronous processing method of Select Channels Go concurrent programming using golang

How to hide the select element in jquery How to hide the select element in jquery Aug 15, 2023 pm 01:56 PM

How to hide the select element in jquery

How to implement change event binding of select elements in jQuery How to implement change event binding of select elements in jQuery Feb 23, 2024 pm 01:12 PM

How to implement change event binding of select elements in jQuery

What is the reason why Linux uses select? What is the reason why Linux uses select? May 19, 2023 pm 03:07 PM

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 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 Oct 05, 2023 am 10:25 AM

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 How to use the select syntax of mysql Jun 01, 2023 pm 07:37 PM

How to use the select syntax of mysql

What does 500internal server error mean? What does 500internal server error mean? Feb 21, 2023 pm 03:39 PM

What does 500internal server error mean?

Implement Select Channels Go concurrent programming performance optimization through golang Implement Select Channels Go concurrent programming performance optimization through golang Sep 27, 2023 pm 01:09 PM

Implement Select Channels Go concurrent programming performance optimization through golang

See all articles