EK5
EK5

Reputation: 122

Firebase Read Operation Calculation

When I use .collection().doc() and specify a document id. Resulting in getting only one document from the collection, does this operation count as one read or as reading all of the documents in the firestore database?

StreamBuilder(
              stream: firestore
              .collection('users')
              .doc(auth.currentUser!.uid)
              .snapshots(),

Additional Question: The .where() query reads all the documents in the collection right? So the total reads is not the amount of documents I get as a result of the query but the total amount of documents in the collection? Thank you.

Upvotes: 0

Views: 78

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 600071

You are only charged for the documents that you read from/on the server. Since you only read one document, it's charged as one read (plus any charges for the bandwidth required to transfer the data).

A query does not read all documents in a collection, but instead uses one or more indexes to determine what documents to read. You are not charged explicitly for those index reads, unless there are no results for a query: in that case you get charged for one document read.

Upvotes: 1

Related Questions