CouchDB 3.x Bookmark Pagination: Unresolved Decision on Auto‑Switch from Skip/Limit
0 reputation · 27 Nov 2022, 13:25 UTC
Goal
Determine whether CouchDB should automatically transition to bookmark‑based pagination when a client issues a skip and limit request that would otherwise trigger deep scanning of the view index.
Context and Constraints
In CouchDB 2.x and earlier, using skip with limit for large result sets forces the database to scan and discard all preceding rows, resulting in O(n) latency that grows with page depth. CouchDB 3.0 introduced the bookmark field in view and _find responses, enabling constant‑time pagination for subsequent pages. However, the initial request still requires a full view build if the view is not materialized, and existing applications rely on skip/limit semantics unchanged.
Unresolved Decision
Should CouchDB automatically switch to bookmark‑based pagination when a client uses skip and limit beyond a certain depth, or should the explicit bookmark API remain the sole mechanism to avoid breaking legacy applications?
Questions
- What threshold of
skipvalue should trigger an automatic switch to bookmark pagination, if at all? - How would such a switch impact backward compatibility for applications that have not been updated to use
bookmark? - What performance guarantees could be offered to clients if automatic switching is implemented?