user8518018
user8518018

Reputation:

Do queries count as readings in Firestore?

If I have 1000 documents and I run a query to find 3 documents that meet a certain condition, will that count as reading 1000 or 3 documents?

Upvotes: 7

Views: 3517

Answers (2)

Doug Stevenson
Doug Stevenson

Reputation: 317467

Document reads are the fundamental unit of billing in Firestore as they relate to queries. Individual queries are not a primary unit of billing, but each query will be billed.

You will be billed for all the documents matched by a query, as those documents will be read and sent to the client. If your query matches no documents, then there is no billing. If your collection has 1000 documents, but your query returns 3 documents, you are charged 3 reads, not 1000.

The exception is that queries that return no documents are billed for a single document read. This means every query incurs a cost of at least one document read, no matter the results. If your query spans multiple requests (because of paging), you are billed at least one document read per request.

Please consult the documentation for Firestore billing to get more detailed information.

Upvotes: 39

Mohammed Rampurawala
Mohammed Rampurawala

Reputation: 3112

As per your query If you are fetching all documents at once on the client end and running your criteria search it will be counted as a single query.

However, if you use the query method of Firestore it will be also counted as a single query.

Note: Don't have references yet, I am telling through the personal experience.

Upvotes: 0

Related Questions