This may be a frequently asked question, but so far I have not been able to find a convincing answer.
In my project, I need to swap for a set of approximately 20,000 records, which is a combined result from several tables, and it needs to be sorted differently in different scenarios.
There are currently two options in front of me:
1, do this using the ie. where dl.[row_number] between @index*@size+1 and @index*@ size+@size database storage procedure ie. where dl.[row_number] between @index*@size+1 and @index*@ size+@size ie. where dl.[row_number] between @index*@size+1 and @index*@ size+@size . The problem is that you have to write Store Procs for each sort separately.
2, do it at the Business Logic level, paging and sorting over the result. (ie. skip(), take()) But this is not ideal, because you can get 20,000 entries, but only 10 of them are used
Is there any standard best practice for this? thanks in advance
sorting sql paging
DJ
source share