Firestore single doc get vs query performance

Viewed 561

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)

1 Answers

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?".

Related