Currently, I am using this recordset paging method: (this example has been cut down for this post)
Function getnext10(num)
pageLen = len(num)
if pageLen = 1 Then
next10 = 10
else if pageLen > 1 Then
pageRem = 10
pageTen = right(num, 1)
next10 = num + pageRem - pageTen
end if
end if
getnext10 = next10
End Function
Function getPrev10(num)
pageLen = Len(num)
If pageLen = 1 Then
prev10 = 1
ElseIf pageLen > 1 Then
l开发者_运维技巧astNumber = Right(num,1)
prev10 = num - lastNumber
End If
If prev10 = 0 Then
prev10 = 1
End If
getPrev10 = prev10
End Function
Which uses a 'Do Until Loop' to get the correct group of results for that page.
I have been advised to drop this method and to start using LIMIT paging instead. I understand how to apply this to my project, I think, so I'm not looking for anybody's code, I just need an explanation as to why I need to start using it.
Apart from using less code in the LIMIT version, which will reduce my page size (mega slightly), why is using the LIMIT method better? Will it improve my search query performance?
Any further clarification on this subject will be gratefully received.
Yes, using LIMIT
would improve the perfomance of your webpage. Right now you're fetching unnessesary records just to move onto right record while LIMIT
would land you onto right record right away. Lets say you have to page 100 records, 10 records per page, and user request page 10 (last page). With the "Do Until Loop" solution you're fetching all 100 records but you discard 90 of them right away, without actually using them. So 90% of the resultset you didn't use for anything constructive! Using LIMIT
you fetch only the records you going to use and thus you aren't wasting any resources.
精彩评论