0

I am using Firebase Firestore to create a log system. The structure is:

  • collection: errors
    • entry for error 1
    • entry for error 2
    • ...

I add an error like so:

val error = hashMapOf(
    "datetime" to FieldValue.serverTimestamp(),
    "errorMessage" to errorMessage
)

database.collection("errors")
    .add(error)

Then I watch at how the costs are affected by this operation. Regarding the write count, it obviously adds 1 write operation.

The problem comes with the read operations. For some reason, executing this code causes:

  • More than 30 reads
  • The read count keep increasing as the time pases, even if I kill the app.

Why a write operation cost so many read operations?

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
svprdga
  • 2,171
  • 1
  • 28
  • 51
  • Note that if you are monitoring your database through the Firebase console, the reads from the Firebase console are included in your read count. – Renaud Tarnec Jun 06 '20 at 11:28
  • I was watching in the firebase website, this means that per each write, if I go to the website and have the top level collection selected, all the elements are counted as a read?? – svprdga Jun 06 '20 at 11:47
  • If by "I go to the website" you mean "I go to the Firebase console" (https://console.firebase.google.com/u/0/), the answer is yes, the reads there are counted in your quota/count. – Renaud Tarnec Jun 06 '20 at 11:48
  • And each time a document is enumerated (NOT opened), this count as a read?? – svprdga Jun 06 '20 at 18:12
  • Yes, since it is the result of a query. There is actually no concept of «is opened»: a doc is fetched with all the fields. A query fetches all the corresponding docs. – Renaud Tarnec Jun 06 '20 at 18:15

1 Answers1

5

Note that if you are monitoring/watching your database through the Firebase console, the Firestore documents reads from the Firebase console are included in your Firestore read count/quota.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121