3

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?

Blodhgard
  • 9,130
  • 3
  • 24
  • 36

1 Answers1

7

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Yes, I have an index on the key. The docs doesn't specify that information. There is only stated that the index is used for performances. Thanks! I will try what you have suggested. – Blodhgard Feb 17 '16 at 00:57