Skip to content

Instantly share code, notes, and snippets.

@islahul
Created July 14, 2015 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islahul/66c0c88493c3d4d15c8e to your computer and use it in GitHub Desktop.
Save islahul/66c0c88493c3d4d15c8e to your computer and use it in GitHub Desktop.
Firebase Complex Query orderByChild() working slow
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