Top 500 SQL data Efficiency Analysis and Methods * from (selecttop500 * fromT1orderbyidasc) aorderbyiddesc first asc takes the first 100 and then reverse (desc) the result of the first results... MSSQL tests the ID field here. If the default ascending sequence is also the primary key column, the following statement can achieve the Efficiency Analysis and method of select * from SQL with tens of millions of data records.
Top 100 * from (select top 500 * from T1 order by id asc) a order by id desc
Asc first obtains the first 500 records and then returns the first 100 results of the result (desc...
MSSQL passed the test here
If the ID field is the default ascending sequence and the primary key column, the following sentence can be implemented.
Select * from t1 where id between 400 and 500
I know three methods: having in between and> = and <=
The efficiency of tested between and should be the highest among the three.
First: id> 400 and id <500 only 99
Id> = 401 and id <= 500 is 100
The best method: Use the FIRST_ROWS (n) optimizer to prompt: The purpose of this optimizer is to increase the SQL statement response time and quickly return n rows first
In addition, between and has the highest efficiency.
Select/* FIRST_ROWS (100 )*/
Id, username from t1
Where id between 401 and 500
Conclusion
From the query point, using between... and is more efficient than obtaining "<" and ">"
Select .*
From table1
Where rownum between 10000001 and 10000101