【发布时间】:2020-03-15 14:27:43
【问题描述】:
hibernate 的 order by 和 Java 的 Collections.sort() 有什么区别? Collections.sort() 的时间复杂度是 O(nlogn) 并且使用 orderBy 必须是 O(1)。但是,数据库处理也必须有一些开销。在无法使用 orderBy 的情况下可以使用 Collections.sort() 吗?
【问题讨论】:
-
Is it okay to use Collections.sort() in cases where using orderBy is not possible?- 是的,为什么不呢? -
orderBy() 仅在数据库服务器可以使用索引时进行优化。