0

enter image description here

I m using firebase Database .Planning to have quite a large data collection , I'm trying to use indexes . Making some tests, i don t know if rules i implement are correct let alone improve the queries .Is there a way to have a feedback on those indexations (correct or not, improve or not)

right now i have one class as described in the picture and i have the created the following rule

{
  "rules": {
    ".read": true,
    ".write": true,
      "users": {
       "$user_id": {
         ".indexOn": ["user_id", "username"]
          }
       },
 }

Since i get no feedback from firebase, i don t know if this is correct and improves anything .

1 Answer 1

1

Firebase's server-side rules are meaningless without seeing the code that exercises them.

But at a first glance it seems you're defining your indexes too low in the tree: indexes need to be defined at the location where you run the query. So if you want to run a query on /users, you need to define the indexes on /users:

{
  "rules": {
    ".read": true,
    ".write": true,
    "users": {
      ".indexOn": ["user_id", "username"]
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Queries are numerous. Thanx for the information Frank. I was also looking for a way to figure out the efficiency of the indexation but i guess there is no easy way to find out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.