现已推出具有 MongoDB 兼容性的 Firestore 企业版!
了解详情。
解決延遲問題
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
僅適用於 Cloud Firestore Enterprise 版。
|
本頁說明如何解決與 MongoDB 相容的 Cloud Firestore 延遲問題。
延遲時間
下表說明延遲時間增加的可能原因:
延遲原因 |
受影響的作業類型 |
解決方法 |
流量持續增加。
|
讀取、寫入 |
如果流量快速增加,與 MongoDB 相容的 Cloud Firestore 會嘗試自動調度資源,以滿足增加的需求。與 MongoDB 相容的 Cloud Firestore 擴充規模後,延遲時間就會開始縮短。
熱點 (對狹窄的文件範圍進行高速讀取、寫入和刪除作業) 會限制與 MongoDB 相容的 Cloud Firestore 擴充能力。檢查
避免熱點
並找出應用程式中的熱點。
|
爭用,可能是因為更新單一文件的頻率過高,或是因為交易。 |
讀取、寫入 |
降低個別文件的寫入速度。
減少單一寫入交易中更新的文件數量。
|
傳回大量文件的大型讀取作業。 |
read |
使用分頁功能分割大型讀取作業。
|
近期刪除次數過多。 |
讀取 這會大幅影響資料庫中列出集合的作業。 |
如果延遲是由近期刪除過多項目所致,問題應會在一段時間後自動解決。如果問題仍未解決,請與支援團隊聯絡。 |
索引扇出,尤其是陣列欄位和內嵌文件欄位。 |
write |
檢查陣列欄位和內嵌文件欄位的索引。 |
大量寫入作業。 |
write |
請嘗試減少每個作業的寫入次數。
如要大量輸入資料,且不需要原子性,請使用平行化的個別寫入作業。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\n\n|--------------------------------------------------------|\n| *Relevant to Cloud Firestore Enterprise edition only.* |\n\n\u003cbr /\u003e\n\nThis page shows you how to resolve latency issues with Cloud Firestore with MongoDB compatibility.\n\nLatency\n\nThe following table describes possible causes of increased latency:\n\n| Latency cause | Types of operations affected | Resolution |\n|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Sustained, increasing traffic. | read, write | For rapid traffic increases, Cloud Firestore with MongoDB compatibility attempts to automatically scale to meet the increased demand. When Cloud Firestore with MongoDB compatibility scales, latency begins to decrease. Hot-spots (high read, write, and delete rates to a narrow document range) limit the ability of Cloud Firestore with MongoDB compatibility to scale. Review [Avoid hot-spots](https://cloud.google.com/firestore/mongodb-compatibility/docs/understand-reads-writes-scale#avoid_hotspots) and identify hot-spots in your application. |\n| Contention, either from updating a single document too frequently or from transactions. | read, write | Reduce the write rate to individual documents. Reduce the number of documents updated in a single write transaction. |\n| Large reads that return many documents. | read | Use pagination to split large reads. |\n| Too many recent deletes. | read This greatly affects operations that list collections in a database. | If latency is caused by too many recent deletes, the issue should automatically resolve after some time. If the issue does not resolve, [contact support](https://firebase.google.com/support). |\n| Index fanout, especially for array fields and embedded document fields. | write | Review your indexing of array fields and embedded document fields. |\n| Large writes. | write | Try reducing the number of writes in each operation. For bulk data entry where you don't require atomicity, use parallelized individual writes. |"]]