I get this warning message from Firebase for every single orderByChild
I used in my queries from JavaScript:
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "" at /tables to your security rules for better performance
So far my queries ran quite fast so I think it is not necessary to include the indexOn
. Just wondering what are the negative impacts?
Also, how do I actually disable the warnings as they are quite irritating when I am debugging.
Firebase provides powerful tools for ordering and querying your data. Indexing can improve the performance of our queries. consider a table called
dinosaur
has some data like:You need to (search) order the dinosaurs height, and length, but never by weight. so you need to set a rules for
dinosaur
table like:By telling Firebase this information, Firebase can use this
.indexOn
to optimize our queries for height and length. Then we maintained Firebase security for querying our data and improve the performance of our queries as well.If you are on development phase, you won't feel the difference. But as your data grows indexing helps making your queries much faster.
Read this to know more on advantages of indexing. https://firebase.google.com/docs/database/security/indexing-data
As far as I know to disable the warnings, you have to edit firebase source code. Is there someway to disable all firebase logging to console?
As the others have said: if you don't define an index, all filtering happens client-side. This is likely fine during initial development, but as you add more data it becomes more and more wasteful.
To fix the problem, define the correct index in your Firebase Database rules. You can modify the rules in the Database panel in your project's Firebase console. See defining data indexes in the Firebase documentation.