When you want to sort and return some data, which logic should you use for sorting?
When receiving any kind of data as a list, is it better to receive the sorted data through Order by on the DB side and use it as it is? Or is it better to not use orderby on the DB side, receive data as it is, and then sort on the spring side?
For reference, spring-boot, jpa, QueryDSL are used, and DB is mysql.
I would appreciate it if you could tell me a better way and why!!!
CodePudding user response:
In general, if you can do it in SQL, do it in SQL.
Database engines are really impressive in executing SQL fast an efficient.
Only if the number of rows is rather limited and the order by is extremely complex to do in SQL, would I consider doing it in the JVM