gpt4 book ai didi

java - Page<> vs Slice<> 什么时候使用?

转载 作者:IT老高 更新时间:2023-10-28 13:49:14 28 4
gpt4 key购买 nike

我读过 Spring Jpa Data documentation当您从存储库中“分页”动态查询时,大约有两种不同类型的对象。

页面切片

Page<User> findByLastname(String lastname, Pageable pageable);

Slice<User> findByLastname(String lastname, Pageable pageable);

所以,我试图找到一些文章或任何东西来讨论两者的主要区别和不同用法性能如何变化以及排序 strong> 影响这两种类型的查询。

有没有人拥有这类知识、文章或一些好的信息来源?

最佳答案

Page扩展 Slice并通过触发计数查询来了解可用元素和页面的总数。来自 Spring Data JPA documentation :

A Page knows about the total number of elements and pages available. It does so by the infrastructure triggering a count query to calculate the overall number. As this might be expensive depending on the store used, Slice can be used as return instead. A Slice only knows about whether there’s a next Slice available which might be just sufficient when walking through a larger result set.

关于java - Page<> vs Slice<> 什么时候使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49918979/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com