Does query size affect Firestore snapshot listeners' performance?



I have 3 active Firestore snapshot listeners in my app, each of which listens to changes inside a different collection (not documents, but the whole collection).

At the moment, the collections’ sizes are small but could get considerably bigger in the future, so would that affect performance at all, or does the size of the collection not matter?

I know there shouldn’t be more than 100 active snapshots at a time, and that it’s not a good idea to keep connecting and disconnecting the listeners frequently, but couldn’t find anything on the actual size of the document/collection to which the listener is attached…


The thing that could make a performance issue is not the size of the queries but the number of changes in a period of time. If you have 3 collections with 1000 documents where every 2 min some document changes that won’t be a big performance deal but if you have 3 collections/queries with 100 documents but they have updates to a lot of them in every few seconds you will notice. Especially if you have state management that is syncing the data between Firebase and the state.

I would detach listeners in queries that get very often updates and leave them for those that stay the same for a while but could get updates. For example in applications with dropdown lists that is a common cause. They often stay the same but could get updates so we listen to them.

Also just to make it clear. The initial loading would of course take longer for each of them if they get larger in size but that should be obvious. Because of the great offline work of Firestore that will only be noticeable on the very first load and later on the user will get the data from cache and then from the server so he won’t notice it.

Answered By – Tarik Huber

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More