gpt4 book ai didi

java - Spring Data JPA 切片底层 SQL

转载 作者:搜寻专家 更新时间:2023-11-01 03:15:25 26 4
gpt4 key购买 nike

我在 Spring Data JPA 官方文档中阅读了这段关于 PageSlice 的区别(强调我的):

The first method lets you pass an org.springframework.data.domain.Pageable instance to the query method to dynamically add paging to your statically defined query. 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), you can instead return a Slice. A Slice only knows about whether a next Slice is available, which might be sufficient when walking through a larger result set.

我知道 Page 如何通过使用相同的 where 子句执行额外的计数查询来获取总元素,但是 Slice 如何知道其他元素是否元素在单个查询中是否可用?执行的SQL是什么?

最佳答案

How does a Slice gets to know whether other elements are available or not with a single query?

Spring Data JPA 选择一个比实际需要多的元素来填充 Slice 如果存在该附加元素,则还有另一个 Slice 可用。如果不是,则这是最后一个 Slice

See the code .

关于java - Spring Data JPA 切片底层 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56176383/

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