pagination: Spring Data JPA Page vs Slice vs keyset Window scrolling, with the SQL and REST shapes

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4bLvQVbZweAqqf54x
This commit is contained in:
Claude
2026-11-16 11:13:56 +05:30
parent e3d1b550ae
commit 91938727f2
42 changed files with 1446 additions and 0 deletions
@@ -0,0 +1,11 @@
# sorting by price, which repeats: 25 books over 4 distinct prices, pages of 5
rows visited: 25, distinct rows: 25, statements: 5
second statement:
select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where (p1_0.category=?) and (p1_0.price>? or p1_0.price=? and p1_0.id>?) order by p1_0.price,p1_0.id fetch first ? rows only
Method 6 names only the price in OrderBy; the id in the statement above was added by Spring Data.
# nullable sort column (H2 sorts NULLs first for ASC)
full window: [b:null, d:null, a:1.00, c:2.00, e:3.00]
after the first row (price null): [d, a, c, e]
select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where (p1_0.category=?) and (p1_0.price is not null or p1_0.price is null and p1_0.id>?) order by p1_0.price,p1_0.id fetch first ? rows only
That predicate is right where NULLs sort first, as on H2. It was not run on a database that sorts them last.