All jobs / Backend developer / Performance

Backend developer interview question · 1–3 years

The interviewer asks: “Why is OFFSET 100000 slow even with a LIMIT 20?” Strongest answer?

The strongest answer

The database still walks and discards the first 100000 rows in the ordered index. Cost grows with the offset. A cursor on the last (sort key, id) seeks instead of skipping.

Why it works

Exactly. OFFSET is “skip N.” Deep pages scan N. Keyset pagination is O(log n) with the right index.

What a good answer covers

Answers that fall short

Who gets asked this

More Performance questions