Querying a Firebase database with a large dataset is very slow

I am using the Firebase database in my Android application. Usually works fine. But as the database grows, query performance degrades. I added about 5 thousand records to the database (under the nodes "elk" and "su"), then I requested the database (on the nodes "cut" and "user"), but all requests are very, very slow. I defined the data index in the database rules, but it did not work. How can I solve this problem?

Here are my questions:

// query to get the zones followed by user
FirebaseDatabase.getInstance()
                .getReference()
                .child("user")
                .child(userID)
                .child("zones");

// query to get cuts on a zone
FirebaseDatabase.getInstance()
                .getReference()
                .child("cut")
                .child(cutType)
                .orderByChild("zoneID")
                .equalTo(zoneID);

my database structure

database rules

+6
source share
1

, , , elk/su . - :

{
    zones: {
        elk: {
            "istan-besik": {                
                "-KSp)bL5....": true,
                ...: true
            }
        }
    }
}

, , :

...child('zones').child(zoneId).child(cutType)

, , /

+2

Source: https://habr.com/ru/post/1656204/


All Articles