Menu

1 / 5

Firestore Offset vs. Cursor Pagination: Cut Read Costs

DEV Community: firebase·Doogal Simpson·12 days ago
#YaYw1GUV
#devtofirebase#devto#dev#offset#firestore
Long article (839 words) — no AI summary yet.
Reading 0:00
15s threshold

Quick Answer: When you run an offset query in Google Cloud Firestore, you are billed for every skipped document read up to your offset count, plus the documents returned. To avoid unexpected read spikes, replace offset() with cursor-based pagination using startAfter() or startAt() , which leverages Firestore's internal indexes to fetch records without paying for skipped data.

Serverless databases feel like magic right up until you receive an invoice for reading documents your users never actually saw.

I have a lot of time for Firestore. It is a solid choice when you need a database that handles spiky traffic without forcing you to pay for an expensive, idle database instance running 24/7. But because Firestore bills on granular operations—per read, per write, and per delete—standard relational database habits will catch you off guard.

The biggest trap?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.