MongoDB database performance

Topics such as replication and sharding are beyond the scope of this book. However, there are a number of things developers can do to optimize the performance of your MongoDB database.

Mainly, we'll talk about cover indexing and tuning queries for performance.

Indexing

In many database systems, adding an index in a field when appropriate can speed up querying. Queries are optimized when performed on indexed fields. MongoDB is no different.

The downside to indexes is that they add some extra time to write operations. They also take up extra space in the database. It makes sense to index wisely. When considering adding indexes, you want to think about whether you expect more read than write operations. This would be a plus ...

Get Mastering JavaScript Single Page Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.