Firebase warning: Using an unspecified index

Viewed 26132

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.

3 Answers

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:

{
  "lambeosaurus": {
    "height" : 2.1,
    "length" : 12.5,
    "weight": 5000
  },
  "stegosaurus": {
    "height" : 4,
    "length" : 9,
    "weight" : 2500
  }
}

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:

"rules": {
  "dinosaurs": {
    ".indexOn": ["height", "length"]
  }
}

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.

Related