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

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

问题描述

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

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

  • 集合:错误
    • 输入错误 1
    • 输入错误 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天全站免登陆