页面<>vs Slice<>什么时候使用哪个? [英] Page<> vs Slice<> when to use which?

查看:45
本文介绍了页面<>vs Slice<>什么时候使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了Spring Jpa Data 文档.

I've read in Spring Jpa Data documentation about two different types of objects when you 'page' your dynamic queries made out of repositories.

页面切片

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

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

因此,我试图找到一些文章或其他文章,讨论两者的主要区别和不同之处,以及性能的变化和排序的方式会同时执行两种查询.

So, I've tried to find some articles or anything talking about main difference and different usages of both, how performance changes and how sorting affercts both type of queries.

有人有这种类型的知识,文章或一些好的信息资源吗?

Does anyone has this type of knowledge, articles or some good source of information?

推荐答案

文档:

Page 知道可用元素和页面的总数.它是通过基础结构触发计数查询来计算总数来实现的.由于根据所使用的商店的不同,这可能会很昂贵,因此可以使用 Slice 作为退货. Slice 仅知道是否存在下一个 Slice ,当遍历更大的结果集时,这可能就足够了.

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.

这篇关于页面&lt;&gt;vs Slice&lt;&gt;什么时候使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆