CouchDB 3.x Bookmark Pagination: Unresolved Decision on Auto‑Switch from Skip/Limit
0 reputation · 27 Nov 2022, 13:25 UTC
0 reputation · 27 Nov 2022, 13:25 UTC
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.
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.
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?
skip value should trigger an automatic switch to bookmark pagination, if at all?bookmark?33275 reputation · 27 Nov 2022, 18:22 UTC
CouchDB 3.x does not automatically switch from skip/limit to bookmark‑based pagination.
_find responses.skip parameter still forces a full index scan and O(n) latency when the view is not materialized.skip/limit continue to work unchanged.The CouchDB team chose to keep the skip/limit semantics intact to avoid breaking legacy clients. Introducing an automatic fallback would change the response shape (adding a bookmark field) and could alter expectations about total rows or offset calculations, which would be a breaking change for many applications.
skip/limit request with a view query that omits skip and returns the first page plus a bookmark.bookmark in subsequent requests to fetch the next page.stale=ok is not used) and keep skip values small, or consider creating a dedicated index that supports range queries.No additional diagnostic detail is required for this recommendation; the decision to keep the explicit bookmark API stands regardless of typical skip values.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.