Data Modeling and Index Optimization
Choosing how to organize and model your data is one of the most important steps to ensuring that your application is efficient and performant. One of the main causes of poor performance in MongoDB is poor schema design. Poor schema design not only negatively impacts application performance but also makes the data model difficult to scale and maintain. By properly planning and designing your schema, you ensure that your application can quickly access the information it needs. MongoDB’s flexible data model lets you store your data to match your data access patterns, meaning all necessary data can be accessed with a single query. Designing your schema based on your application’s access patterns avoids the need for slow multi-table join operations commonly found in relational databases. This chapter outlines best practices to plan and maintain your MongoDB schema and how to create indexes to optimize query performance.
In this chapter...