Created
July 14, 2015 10:11
-
-
Save islahul/66c0c88493c3d4d15c8e to your computer and use it in GitHub Desktop.
Firebase Complex Query orderByChild() working slow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem: | |
Slow response on complex query method orderByChild("key") | |
Inspection: | |
Check the websocket frames on Chrome DevTools. | |
If it is loading unnecessary data, it means that Firebase is doing the query on client side. (Yes, it's not in the documentation but it does that) | |
Solution: | |
Add indexing in Security rules | |
Example: | |
DB: | |
{ | |
"collection": { | |
"item_id": { | |
"key": 1, | |
"another_key": "veg" | |
} | |
} | |
} | |
Security Rules: | |
"collection": { | |
".indexOn": ["key", "another_key"] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment