Alex Rivera | Logout

SQL Sorting: server vs. client

Asked 2010-10-27T02:53:13.410
9

Most of the times, when it comes to sort some data, we have two options:

  1. Sort on the SQL server -- use ORDER BY clause
  2. Sort on client one we get the data from the database

When would you use one over the other and why?

Edit
Report

1 Answer

24

Always sort where possible in the SQL server.

The SQL abstracts away the steps of querying the database, sorting, etc. Use as much abstraction as you can - why would you select a bunch of rows, and then write a sorting algorithm when you can do it in the SQL with ORDER BY.

See also Bill Karwin's answer.

answered 2010-10-27T02:55:54.050

Your Answer