2
votes

extra question to: Queries scale with the size of your result set, not the size of your data set

Maybe this is a bit old but I still want to ask this. What is about the document size?

Is it equally fast to query 10x 1mb results out of 1000 AND querying 10x 1kb results out of 1000? I am curious about this on the Cloud Functions backend side. So I only want a part of the data from my collection query result using cloud functions and creating an API that queries the entire result (10x 1mb) and returns to the client only a part of the data. Or is it faster to store the partial documents in a separate collection and querying on this collection?

So would it be the same performance without taking the data transfer to the client in consideration?

1

1 Answers

7
votes

The query performance is dependent on the size of the result. Since 10Mb is larger than 10Kb, it will be slower to get 10Mb than it is to get 10Kb. That applies both to the transfer over the network as to the reading of the data from disk or memory. Reading more data simply takes more time.

The guarantee Firestore makes is that the amount of data in the collection has no effect on the query performance. So if you get 10Mb of data from 10Gb of data in the collection, it will take the same amount of time as when you that the same 10Mb from a 10Tb collection.