Improve Pagination Performance In SQL Server
Mesh
Updated Apr 9, 2021, 02:38 PM
So I had a case today where if I wanted to paginate over 60k document pages that pagination was very slow for the pages at the end of the document pages, I looked for a solution and found this:
Apparently the fastest way to paginate in SQL is by comparing with the keys of the tables, for example:
SELECT id, SomeOtherColumn FROM Pages WHERE id > 'some id' -- also can add: AND Id < 'some other id' ORDER BY id ASC -- can use DESC for previous
That's it, might try it out soon since the number of pages is getting a lot higher, although I might not need it, but oh well :D
Ciao
