Docs Home / Compass / Interact with Your Data / View Performance

Performance Insights性能洞察

When MongoDB Compass determines that your schema or queries can be improved, it displays a performance insight. Performance insights show ways to improve your schema and data modeling practices. Use performance insights to learn best schema design practices and improve application performance.当MongoDB Compass确定模式或查询可以改进时,它会显示性能洞察。性能洞察展示了改进模式和数据建模实践的方法。使用性能洞察来学习最佳模式设计实践并提高应用程序性能。

Use Cases用例

Performance insights are best followed early in your application development process. Starting your application with good data modeling practices helps prevent schema and performance issues as your application grows.最好在应用程序开发过程的早期遵循性能见解。使用良好的数据建模实践启动应用程序有助于在应用程序增长时防止模式和性能问题。

Although Compass provides performance insights at any stage of development, it can be difficult to make schema modifications in large-scale schemas that are used in production.尽管Compass在开发的任何阶段都提供了性能见解,但在生产中使用的大规模模式中进行模式修改可能很困难。

Before you modify your schema based on performance insights, ensure that the suggestion makes sense for your application. For example, if Compass suggests creating an index, make sure that index supports queries that are run frequently.在根据性能见解修改模式之前,请确保该建议对应用程序有意义。例如,如果Compass建议创建索引,请确保该索引支持频繁运行的查询。

Behavior行为

Performance insights are enabled automatically.性能洞察会自动启用。

Performance insights are generic, and do not use properties specific to your schema such as database or collection names.性能洞察是通用的,不使用特定于模式的属性,如数据库或集合名称。

Compass shows performance insights in the following scenarios:Compass显示了以下场景中的性能见解:

Scenario场景Performance insight性能洞察力
You run a query or aggregation without an index.您在没有索引的情况下运行查询或聚合。Add an index to support the operation.添加索引以支持该操作。
You run an aggregation pipeline that uses a $lookup stage.您运行一个使用$lookup阶段的聚合管道。Embed related data to avoid the need for a $lookup operation.嵌入相关数据以避免需要$lookup操作。
You run a $text or $regex query.您运行$text$regex查询。If possible, use Atlas Search to improve performance for text search queries.如果可能,请使用Atlas Search来提高文本搜索查询的性能。
Your database contains too many collections.数据库包含的集合太多。Reduce the number of collections.减少集合数量。
Your documents contain an array field with too many elements.文档包含一个元素过多的数组字段。Avoid unbounded arrays.避免使用无界数组。
The data size of individual documents is too large.单个文档的数据大小太大。Break up large documents into separate collections.将大型文档拆分为单独的集合。
Your collection contains too many indexes.集合包含的索引太多。Review your indexes and remove any that are unnecessary.检查索引并删除任何不必要的索引。

Learn More了解更多

  • To learn more about data modeling in MongoDB, see Data Modeling.要了解有关MongoDB中数据建模的更多信息,请参阅数据建模
  • To learn how to create effective indexes for your application, see Indexing Strategies.要了解如何为应用程序创建有效的索引,请参阅索引策略