Blodhgard
Blodhgard

Reputation: 9385

Firebase database bandwidth usage when read with Query

I'm using Firebase in my android app, and I've noticed that the app use a lot of bandwidth. I execute only read in the lower nodes childs like stated in the best practise to save bandwidth.

If I execute a query like this:

Query queryRef = firebaseRef.orderByChild("internalKey").equalTo(false);
queryRef.addListenerForSingleValueEvent(new ValueEventListener()
        {
           ...

In the database bandwidth usage are counted all the child node or only those with internalKey = false?

Upvotes: 3

Views: 1602

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599956

The bandwidth counts the amount of data that you upload and download. It's really as simple as that.

If you have defined an index on internalKey, then Firebase will filter the data on its servers and return only the elements matching the condition.

However, if you don't have an index on internalKey, all the data will be downloaded to the client and the client will then do the filtering. You should also see a warning about that in logcat iirc.

When you see large bandwidth usage, I recommend enabling debug logging (Firebase.getDefaultConfig().setLogLevel(Level.DEBUG)) and checking if the traffic in logcat matches your expectation.

Upvotes: 7

Related Questions