Hello all, I have a database, which I query, and I'm unsure of where to perform the sorting of the results, so far I've have the following options.
- At the MySQL query.
- At list level(Using a LinkedList)
- Sorting an unsorted list using comparators before showing the results (basically in the jsp)
The List is composed by ObjectDTO so where would it be more efficient. Any ideas?
You should do the sorting in the database if at all possible.
- The database can use indexes. If there is a suitable index available then the results can be read from disk already in sorted order, resulting in a performance increase - no extra O(n log(n)) sorting step is required.
- If you only need the first
xresults you also minimize data transfer (both reduced network transfer, and also reduced disk access if there is a suitable index).