Does Firebase charge more money in the first over the second scenario?
collection().get() // potentially retrieves infinite documents
collection().limit(smallerAmount).get() // only retrieve a smaller amount of documents
In the documentation, there is some none billed traffic within GCP, but I am not sure if this applies to Firestore read requests.
I am assuming that billing is the same for Cloud Functions as it is for my client and that the more documents are retrieved by a get()
call the more one gets charged.
Yes, the first case charges more money, compare to the second case.
As stated in the doc you refer to (i.e. https://firebase.google.com/docs/firestore/pricing#operations):
Since your result set is smaller in the second case (because you use
limit()
) you are going to have less documents added to the result set.For the case of Cloud Functions reading data of Firestore, if the region of your Cloud Function is not the same than the one of your Firestore (and is not in the same multi-region), you will pay for the Egress between regions. See, again, the doc you refer to as well as https://firebase.google.com/docs/functions/locations#selecting_regions_for_firestore_and_storage
Update, from the comments below
For the connection between the Cloud Functions and Firestore:
Egress within a region -> free, Egress between regions in the same multi-region -> free, Egress between regions (NOT in the same multi-region) -> not free, prices different if US or not US. See the table at the bottom of https://firebase.google.com/docs/functions/locations#selecting_regions_for_firestore_and_storage for details on the respective regions
Note also that, for Firestore, for the moment, the only available multi-region location is us-central, see https://firebase.google.com/docs/firestore/locations
Your question is asking several questions that are not really related to each other.
First, document reads are not the same as egress and ingress. A document read is a result of simply making a query that requires the access of a document in Firestore. It doesn't take into account the amount of network data required to send the contents of that document, which is called egress.
Second, egress is measured only by the number of bytes transferred from your cloud services. Egress may not be charged when the data stays within a region - the documentation will be clear on that. Egress has nothing to do with the billing for document reads.
Third, document reads are charged no matter where the request originates. Think of it as the cost of using a Firestore index to make queries fast. It has nothing to do with egress, and everything to do with the number of documents that must be touched to satisfy the query.
Fourth, any query that reads more documents than another query will cost more. You are only charged for document reads where the contents of the documents must be transferred to the client.