Java – where do I sort?

I have a database, I query, I don't know where to perform the sorting of results, so far, I have the following options

>Query in MySQL. > At the list level (using LinkedList) > sort the unordered list (basically in JSP) using a comparator before displaying the results

The list consists of objectdto, so where will it be more efficient Any ideas?

Solution

If possible, you should sort in the database

>Databases can use indexes If an appropriate index is available, the results can be read from the disk in sort order, resulting in improved performance – no additional o (n log (n)) sort steps are required. > If you only need the first X result, you can also minimize data transmission (reduce network transmission and disk access if appropriate indexes exist)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>