lurning too koad
lurning too koad

Reputation: 2974

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).

Upvotes: 4

Views: 1275

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317968

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.

Upvotes: 2

Related Questions