In terms of the memory and CPU usage, which one is better, sorting a resultset in SQL Server or in .NET?
For example, I have a stored procedure called csp_Products
that returns 1000 rows - the result should be sorted by product name, is it better to sort this in SQL Server using an ORDER BY
clause or is it better to do this in .NET after the data has been retrieved?
If you can do it in SQL Server with an ORDER BY
clause, then do it. SQL Server is made for retrieving and manipulating data and will be faster.
That being said, depending on the type of data being returned and the number of rows there may not be a noticeable difference. 100 rows really isn't that much data to have to worry about performance.
I would go for SQL server since it can use indexes (if there are any it can take advantage of)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With