Performance depending on the number and order of filters? #370
-
Is there any performance gain in the order of applying filters? Is there any negative or positive impact depending on the number of filters used? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There is no indexing so indeed the more filters you have the slower it gets as every record in a given store will be checked. The algorithm is dumb so indeed the order could have some impact (in a AND the first filter will be checked first). If you really want to optimize the filter, the faster will be to use a custom filter where you access the raw data of each record directly. A query with complex filtering with lots of data could be slow for each getSnapshots call, however onSnapshots will be smart enough to only check the filtering on modified records. |
Beta Was this translation helpful? Give feedback.
-
That's correct. And in the same way if the first condition of a OR is met it does not check the others too. |
Beta Was this translation helpful? Give feedback.
There is no indexing so indeed the more filters you have the slower it gets as every record in a given store will be checked. The algorithm is dumb so indeed the order could have some impact (in a AND the first filter will be checked first). If you really want to optimize the filter, the faster will be to use a custom filter where you access the raw data of each record directly.
A query with complex filtering with lots of data could be slow for each getSnapshots call, however onSnapshots will be smart enough to only check the filtering on modified records.