im trying to understand the firebase pricing model and I stumbled over this. https://firebase.google.com/docs/firestore/pricing
Queries other than document reads
For queries other than document reads, such as a request for a list of collection IDs, you are billed for one document read. If fetching the complete set of results requires more than one request (for example, if you are using pagination), you are billed once per request.*
Let's say Im fetching 10 profiles from a profiles collection (10.000 documents) randomly limit(10) it would cost me 10 reads.
return FirebaseFirestore.instance
.collection('profiles')
.limit(10)
.get()
.then(...)
Now I want to show my 10 results in the UI and I also want to show the clients a heart icon which is filled if the client liked the profile or not. I would fetch the user data and check if the user liked one of the 10 profiles. I already learned storing the user specific data in the same collection profiles doesn't make sense, lets say we are saving it in a users collection subcollection called profilelikes:
return FirebaseFirestore.instance
.collection('users')
.doc('userId')
.collection('profilelikes')
.get()
.then((QuerySnapshot querySnapshot) => {
querySnapshot.docs.forEach((doc) {
if () {
// check if profiles from list matches userprofile document
}
})
});
What does it mean for this case exactly? Lets say the user has 5000 documents inside the profilelikes Im searching in 5000 documents if 10 of them are matching or not. Let's say 2 of them are matching:
How many costs do we have here?
First Query: 10 reads because we have 10 results here Second Query: ???