SQL Server 2012 introduced the fetch and offset feature.
Laravel started using FETCH and OFFSET in 2021 -- but only when you include an order by: laravel/framework#39863
Laravel also only officially supports 2017 and up: https://laravel.com/docs/9.x/database#introduction
This PR updates the query builder to also use FETCH and OFFSET for queries that do not include an order by: laravel/framework#44458
Lower is better, see: https://github.com/dunhamjared/laravel-benchmarks
Current method:
select * from (select *, row_number() over (order by (select 0)) as row_num from [users]) as temp_table where row_num between 9991 and 10000 order by row_num;
Proposed method:
select * from [users] order by (SELECT 0) offset 9990 rows fetch next 10 rows only;