Engineering Decisions · Middle · Question 9 of 14

An activity log has 50M rows, and OFFSET gets slower on deep pages. The UI only has "Older" and "Newer" buttons. How do you paginate?

Show the answer

Correct answer: Keyset pagination on (created_at, id)

Explanation

Keyset pagination seeks through an index, so depth doesn't affect speed, and next/previous buttons are all it needs. Caching fits a list that rarely changes, but a log grows constantly, so cached pages shift. A depth cap fits search results, where nobody goes deep, while here it would hide old records that people may need.

Further reading

Problem with a question

Engineering Decisions · Middle · question 9

Test yourself

Take the Engineering Decisions · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz