Pros and cons of sorting data in DB?

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2010-05-17T11:43:57Z Indexed on 2010/05/17 11:50 UTC
Read the original article Hit count: 250

Filed under:
|
|
|
|

Let's assume I have a table with field of type VARCHAR. And I need to get data from that table sorted alphabetically by that field.

What is the best way (for performance): add sort by field to the SQL-query or sort the data when it's already fetched?

I'm using Java (with Hibernate), but I can't tell anything about DB engine. It could be any popular relational database (like MySQL or MS Sql Server or Oracle or HSQL DB or any other).

The amount of records in table can vary greatly but let's assume there are 5k records.

© Stack Overflow or respective owner

Related posts about database

Related posts about hibernate