Home > Software engineering >  Does Firebase onWrite count as extra read?
Does Firebase onWrite count as extra read?

Time:03-10

I’m wondering if accessing the data from the “change” snapshot of the onWrite cloud function count as an extra read on my billings.

Thank you!

CodePudding user response:

The data from the database that is included with the payload that triggers your Cloud Function does not count as a charged read towards your database (either Firestore or Realtime Database), since they are served from within an existing data stream.

CodePudding user response:

As per the documentation,

Cloud Firestore allows you to listen to the results of a query and get realtime updates when the query results change.

When you listen to the results of a query, you are charged for a read each time a document in the result set is added or updated. You are also charged for a read when a document is removed from the result set because the document has changed. (In contrast, when a document is deleted, you are not charged for a read.)

Also, if the listener is disconnected for more than 30 minutes (for example, if the user goes offline), you will be charged for reads as if you had issued a brand-new query.

This means that you'll be charged on the 1st read of the listener and will only charge you if there are changes or writes on the current snapshot.

  • Related