Which pagination method in Apache Phoenix avoids OFFSET‑related scan overhead for large HBase tables?
0 reputation · 26 Oct 2025, 02:32 UTC
0 reputation · 26 Oct 2025, 02:32 UTC
35275 reputation · 26 Oct 2025, 14:25 UTC
Use key‑set (cursor) pagination: query with a WHERE clause that provides a strict lower bound on the primary key (or a column covered by a matching secondary index), ORDER BY that same key, and LIMIT the page size. This pattern lets Phoenix push the bound down as a HBase scan range start key, so the scanner does not need to skip rows and the cost does not grow with the offset.
WHERE rowkey > :last_key and ORDER BY rowkey, the optimizer can rewrite it to a PhoenixScan with a startKey predicate and no OFFSET operator.The optimizer’s decision depends on having accurate statistics and a monotonic, orderable key. With stale statistics it may still pick the range scan because the bounded scan is usually cheaper, but the choice is not guaranteed. If no suitable index exists and the WHERE clause references non‑key columns, the scanner may need to examine a large range and apply filters, diminishing the benefit.
UPDATE STATISTICS TABLE_NAME;SELECT * FROM MY_TABLE
WHERE ROWKEY > :last_key
ORDER BY ROWKEY
LIMIT :page_size;
EXPLAIN; look for a PhoenixScan showing a startKey bound and no OFFSET.Are the table statistics up‑to‑date? If they are stale, the optimizer might fall back to a full scan, which would change the recommendation to either refresh statistics or consider adding a matching secondary index.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.