Home > database >  Data paging efficiency - logical reads
Data paging efficiency - logical reads

Time:05-03

In the data query analysis logical reads what reaction? Multiple nested query logic reads less instead?
As in a 100 w data in the table to perform paging query, now has written several SQL, are respectively in 2012 after the new Offset, Fetch Next page, and 2005 new row_number, code is as follows:
 
Declare @ pageIndex int=800;
Declare @ pageSize int=20;
- paging query 1
Select * From [order] order By id asc Offset (@ pageIndex - 1) * @ pageSize Rows Fetch Next @ pageSize Rows Only
- paging query 2
SELECT * FROM [order] WHERE ID IN (
SELECT the ID FROM (SELECT ID, ROW_NUMBER () OVER (asc) ORDER BY ID AS num FROM [ORDER]) AS settable
WHERE num is BETWEEN (@ pageIndex - 1) + 1 AND @ pageIndex * * @ pageSize @ pageSize)
- paging query 3
SELECT * FROM (SELECT ROW_NUMBER () OVER (ORDER BY id) AS rids, * FROM [ORDER]) AS t
WHERE t.r id between (@ pageIndex - 1) + 1 AND @ pageIndex * * @ pageSize @ pageSize



(20 rows affected)
Table "Order", scanning count 1, logical reads 1455, physical reads 0, page server reads 0, pre-reading reads 0, proofread the page server reads 0, LOb logical reads 0, LOb logical reads 0, LOb server page reads 0, LOb to proofread reads 0, LOb proofread the page server reads 0,

(20 rows affected)
Table "Order", scanning count 1, logical reads 89, physical reads 0, page server reads 0, pre-reading reads 0, proofread the page server reads 0, LOb logical reads 0, LOb logical reads 0, LOb server page reads 0, LOb to proofread reads 0, LOb proofread the page server reads 0,

(20 rows affected)
Table "Order", scanning count 1, logical reads 1543, physical reads 0, page server reads 0, pre-reading reads 0, proofread the page server reads 0, LOb logical reads 0, LOb logical reads 0, LOb server page reads 0, LOb to proofread reads 0, LOb proofread the page server reads 0,

CodePudding user response:

Logical reads "refers to the number of pages read from the cache.
  • Related