Improving efficiency when sorting all records in a  table