firebasegoogle-cloud-platformgoogle-cloud-firestore

Firestore too much read on 1 document while using Firebase console


I am just trying to learn Firestore and see a lot of reads on my Firestore console.

I have 160+ reads for 1 document only in my other project when in fact in my app I haven't even implemented a script that will read from database yet. I simply had made a register form to write on my database, I then use the console to see if my input was on the database which is there.

From my understanding 1 read only counts to 1 document regardless how many fields it has. I am also aware that viewing documents on the console also count as read but what I was surprised was every time I refresh the Firestore console it gives me 4-5 reads per refresh on a single document. At first I thought it was because I always leave the console on background but I am not even adding new data and just simply refreshing the console and it also happens when I refresh on the usage tab it sometimes add 1 read.

So I tried to replicate it in a different project. I added a collection and 1 document using the console only no apps connected. Then I refreshed for about 14-15 times then I got 56 total reads for 1 document only. Am I the only one having this problem?

I have some screenshots below:

enter image description here

enter image description here


Solution

  • firebaser here

    The Firestore console causes quite some reads that you may not immediately think of. Some things the Firestore console does, that lead to document read charges:

    1. it get the list of collections (which counts as a charged document read),
    2. it reads the document IDs for the middle list in your screenshot, which counts as one document read for each ID shown
    3. then it reads the data for the selected document, which (if I recall correctly) is at least one more read
    4. then it attaches some listeners to show realtime updates
    5. there might be another read to determine what chips to show in the search options in the center column too.

    All of these combined indeed might well add up to the numbers you see. There's definitely some room for optimization on our end here, but it'll always charge multiple document reads simply because of the number of documents/document IDs it shows.


    Trying to explain the document read charges on this level also doesn't help you gauge how your charges will change as your actual usage from client scales.

    The way I usually check/estimate the usage of my apps is by going straight to the usage tab of the Firestore console, and then running the relevant use-case in my app a few times. That way any reads that show up in the charts must come from my application code, or at the very least: can't come from the data being shown in the Firestore console.