5 exercises on API pagination strategies vocabulary.
0 / 5 completed
1 / 5
What is the main drawback of offset/limit pagination on large datasets?
Offset pagination:OFFSET 100000 LIMIT 20 forces the database to count and discard 100000 rows before returning results, getting slower as the offset grows. It also risks skipped/duplicated rows when data changes.
2 / 5
How does cursor (keyset) pagination improve on offset pagination?
Cursor pagination: instead of skipping N rows, it queries WHERE id > last_seen_id ORDER BY id LIMIT 20. With an index this stays fast at any depth and is stable under concurrent inserts.
3 / 5
Why is cursor pagination more stable when rows are inserted or deleted during paging?
Stability: offset pagination shifts when rows are added or removed, causing items to be skipped or repeated. Keyset pagination anchors on a stable column value, so concurrent changes do not corrupt the sequence.
4 / 5
What is a trade-off of cursor pagination compared to offset?
Trade-off: cursor pagination is sequential - it gives next/previous pages efficiently but not random access to page 50 - because it has no notion of absolute position, only relative to a cursor.
5 / 5
For an infinite-scroll mobile feed, which pagination is generally best?
Infinite scroll: cursor pagination fits naturally since the client only ever needs the next batch after the last item. It stays performant and avoids the duplicate/skip problems offsets cause on changing feeds.