Skip to content

REST pagination total count (Prefer: count=) #2162

Description

@cb1kenobi

Tracking issue for the REST pagination total-count feature so we can attach priority and track its dependencies.

What

Let REST collection queries return the total number of matching records for pagination, opt-in via the Prefer request header, surfaced in RFC 7233-style response headers (Content-Range: items <start>-<end>/<total>, Range-Unit, Preference-Applied).

  • Prefer: count=estimated — cheap planner/table estimate; the safe default.
  • Prefer: count=exact — precise, but scans the full matched set, so it is opt-in per REST mount via rest: { exactCount: true } (default off). Otherwise served as an estimate.
  • GET/HEAD only; requires a bounded limit(); exact scans are bounded by a row cap + wall-clock budget.

Initial implementation: #2147.

Dependency / follow-up

Estimated counts are only as good as our range-count estimation. Accurate estimates for range conditions (>, <, BETWEEN, starts_with, etc.) depend on better cardinality estimation in the storage engine — see HarperFast/rocksdb-js#311. Until then, count=estimated falls back to Content-Range: .../* (unknown) for conditions with no cardinality estimate.

Worth deciding whether improved range estimation should be a prerequisite for broader rollout / enabling exact by default.

Docs

HarperFast/documentation#623

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

Priority

None yet

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions