How can a cursor resume after the last tied row on a page?
Compare the ordered key tuple against the last emitted tuple to define the next page's lower bound.
SQLite example and interpretation
After (8,1), resume at (8,2) and then (9,3). This form assumes non-null ascending keys. A consistent snapshot matters when pages span concurrent writes.
WITH r(s,id) AS (VALUES(8,1),(8,2),(9,3)) SELECT s,id FROM r WHERE (s,id)>(8,1) ORDER BY s,id LIMIT 2;Result [[8, 2], [9, 3]]
中文
怎样从上一页最后一个同分样本之后继续读取?
按相同顺序比较一组排序键,并用最后一行的键作为下一页下界,即可定位后续记录。
SQLite 示例与适用条件
游标 (8,1) 之后先读同分的 (8,2),再读 (9,3)。此写法假定键非空且均升序,跨页数据还需一致的读取时点。
WITH r(s,id) AS (VALUES(8,1),(8,2),(9,3)) SELECT s,id FROM r WHERE (s,id)>(8,1) ORDER BY s,id LIMIT 2;结果 [[8, 2], [9, 3]]