【发布时间】:2021-10-12 06:08:19
【问题描述】:
如Firestore usage and limits 中所述,对文档的最大持续写入速率为每秒 1 次。它是否也适用于batch 写入,还是已经遵守此限制?
我知道这是一个软限制,但根据Best practices for Cloud firestore: “请特别注意文档每秒 1 次写入的限制和每个数据库 1,000,000 个并发连接的限制。这些是 Cloud Firestore 不会阻止您超过的软限制。但是,超过这些限制可能会影响性能,取决于你的总读写率。”
例如,下面的代码块是否有问题,或者批量写入会相应地处理它?
const testRef = firestore.collection("testCollection").doc("testDoc");
const testRef2 = firestore.collection("testCollection").doc("testDoc2");
const batch = db.batch();
batch.update(testRef, {
test1: "test1",
});
batch.update(testRef, {
test22: "test22",
});
batch.update(testRef, {
test33: "test33",
});
batch.update(testRef2, {
test444: "test444",
});
batch.update(testRef2, {
test5555: "test5555",
});
await batch.commit();
【问题讨论】:
-
完成,谢谢@FrankvanPuffelen
标签: firebase google-cloud-firestore