Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much does the size of the array in an array-contains Firestore query impact performance?

In an array-contains Firestore query (not array-in or array-contains-any), how much does the size of the array impact the performance of the query? I have five sets of data that I could, for the purposes of this query, combine into a single array. However, if the array-contains query prefers smaller arrays, I could split the data into five arrays. I'd prefer, for simplicity, to use a single array but I'd rather make Firestore happy, not me. Each set of data has less than 25 elements (so not large at all).

like image 687
kidcoder SAVE UKRAINE Avatar asked Sep 16 '25 16:09

kidcoder SAVE UKRAINE


1 Answers

The performance impact is negligible. Each item in the field value is going to be part of a massively scalable index whose performance is not going to be impacted by a few more elements. Bear in mind also that the maximum total size of a single document is 1MB, so there is really only so much data you can even store in a single field that can compare to the overall size of a collection.

The general performance characteristic of Firestore queries is that they scale with the size of the result set (number of documents matched and returned), not the the size of the source data (total number of documents queried). The size of a single document's array field doesn't impact this enough to be noticeable. Feel free to benchmark if you have concerns.

like image 65
Doug Stevenson Avatar answered Sep 18 '25 10:09

Doug Stevenson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!