Reputation: 428
Is there any performance difference between performing a get
operation on a single document reference vs performing a query operation to retrieve that single document ? for example:
collection('users').document('uid').get()
vs collection('users').where('uniqueField', '==', 'uniqueValue').get()
(given the query operation is performed on a unique value, ie only one document per value)
Upvotes: 6
Views: 1472
Reputation: 83048
Have a look at the third sub-question of this question and the corresponding answer.
Since your query returns only one document the answer to the above question applies: "The performance difference is negligible. Firestore queries all perform based on the total number of documents retrieved, not the number of documents in the collection".
For more info why Firestore is working like that I would suggest you watch the following official video about "How do queries work in Cloud Firestore?".
Upvotes: 2