为什么在Firestore中写入1个文档需要30次读取? [英] Why 1 document write in Firestore costs +30 reads?

查看:61
本文介绍了为什么在Firestore中写入1个文档需要30次读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase Firestore创建日志系统.结构是:

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

  • 集合:错误
    • 输入错误1
    • 输入错误2
    • ...
    • collection: errors
      • entry for error 1
      • entry for error 2
      • ...

      我添加了这样的错误:

      val error = hashMapOf(
          "datetime" to FieldValue.serverTimestamp(),
          "errorMessage" to errorMessage
      )
      
      database.collection("errors")
          .add(error)
      

      然后,我观察此操作如何影响成本. 关于写入次数,显然要增加1次写入操作.

      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:

      • 超过30次阅读
      • 即使我杀死了该应用程序,读取计数也随着时间的流逝而不断增加.

      为什么写操作要花费那么多读操作?

      Why a write operation cost so many read operations?

      推荐答案

      请注意,如果要通过 Firebase控制台,从Firebase控制台读取的Firestore文档包含在Firestore读取计数/配额中.

      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.

      这篇关于为什么在Firestore中写入1个文档需要30次读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆