The Row That Vanished
A feed endpoint uses keyset pagination. The cursor is a base64 blob holding the last row's updated_at and id.
def page(cursor, limit=50):
if cursor:
ts, last_id = decode(cursor)
rows = db.query(
"SELECT * FROM posts "
"WHERE (updated_at, id) < (%s, %s) "
"ORDER BY updated_at DESC, id DESC LIMIT %s",
ts, last_id, limit)
else:
rows = db.query(
"SELECT * FROM posts ORDER BY updated_at DESC, id DESC LIMIT %s",
limit)
nxt = encode(rows[-1].updated_at, rows[-1].id) if rows else None
return rows, nxt
Users report that posts occasionally never appear, no matter how far they scroll. Which interleaving explains it?
Sign in to answer questions and track your progress
Sign In