Explain the difference between Offset-based and Cursor-based pagination, and in what scenarios is cursor-based strictly better?
Last updated
Offset pagination skips N rows (
LIMIT 20 OFFSET 40): simple with random page access, but slow at deep offsets and prone to skipped/duplicate rows when data changes.Cursor pagination fetches items after an opaque pointer to the last seen row (
WHERE id > :cursor): index-backed, fast at any depth, and stable under inserts/deletes.Cursor is strictly better for very large or high-write feeds (timelines, logs). Offset still suits small, stable, page-numbered UIs.
- https://stripe.com/docs/api/issuing/authorizations/list?country=1210&__hstc=192971698.65337744294b740e0787aea508c4a702.1577664000184.1577664000185.1577664000186.1&__hssc=192971698.1.1577664000187&reviews_page=0&source=post_page---------------------------&__hsfp=3969827736&portalId=53&_preview=true&cacheBust=1594720451930&preview_key=pSOAWoAu&inpageEditorUI=true&benderPackage=InpageEditorUI&staticVersion=static-1.22392&scriptPath=bundles%2Fapp.js&cssPath=bundles%2Fapp.css&hubs_signup-url=preview.hs-sites.com/_hcms/preview/content/5241498400&hubs_signup-cta=null&hubs_post=blog.hubspot.fr/marketing/questions-refonte-site-web&hubs_post-cta=hsg-nav__box-link&offset=1710&limit=45
- https://www.interviewbit.com/node-js-interview-questions/