<br />

<br />

|--------------------------------------------------------|
| *Relevant to Cloud Firestore Enterprise edition only.* |

<br />

This page shows you how to resolve latency issues with Cloud Firestore with MongoDB compatibility.

## Latency

The following table describes possible causes of increased latency:

|                                      Latency cause                                      |                       Types of operations affected                        |                                                                                                                                                                                                                                                                          Resolution                                                                                                                                                                                                                                                                          |
|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------| |
| 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. |
| 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.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Large reads that return many documents.                                                 | read                                                                      | Use pagination to split large reads.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| 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).                                                                                                                                                                                                                                                                                                                                                               |
| Index fanout, especially for array fields and embedded document fields.                 | write                                                                     | Review your indexing of array fields and embedded document fields.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 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.                                                                                                                                                                                                                                                                                                                                                                                                              |