Reputation: 161
In a Q&A application with Firebase backend, a Post contains the question, answers and replies to each answer. The documents of collection replies
have two fields: questionId
and answerId
To get replies to a particular answer, there are two methods of query
firebase.firestore().collection('replies').where('answerId','==',answerId).get()
firebase.firestore().collection('replies').where('questionId','==',questionid).where('answerId','==',answerId).get()
Considering the number of questions is much greater than the number of answers, does method 2 have better performance than method1? Also possible delay caused by composite query is also considered.
Upvotes: 1
Views: 82
Reputation: 317750
The performance of a Firestore query is based on only one thing: the number of documents in the result set. If your two queries return the same number of results, then they have the same overall performance. Adding or removing filters does not change this at all.
Upvotes: 2