title: Pros and cons of sorting data in DB?
body: <p>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. </p>
  
  <p>What is the best way (for performance): add <code>order by field</code> to the SQL-query or sort the data when it's already fetched?</p>
  
  <p>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).</p>
  
  <p>The amount of records in table can vary greatly but let's assume there are 5k records.</p>
  
  <p>UPD: how well does 2nd level hibernate cache (EHCache for example) support sorted data?</p>