对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

分析慢速查询

Cloud Manager提供多种工具来帮助分析在集群上执行的慢速查询。 有关每个工具的说明,请参阅以下部分。 要优化查询性能,请查看查询性能最佳实践。

Performance Advisor监控慢速queries并建议新索引以提高查询性能。

您可以使用性能优化顾问查看以下信息:

Monitor collection-level query latency with Query Insights. You can view query latency metrics and statistics for certain hosts and operation types. Manage pinned namespaces and choose up to five namespaces to show in the corresponding query latency charts.

分析器显示运行缓慢的操作及其关键性能统计信息。 您可以探索过去 24 小时内的历史查询样本,而不会产生额外的性能开销。 在启用分析器之前,请参阅注意事项。

要优化查询性能,请查看以下最佳实践:

  • 创建当前索引支持的查询,以减少搜索结果所需的时间。

  • 避免创建包含大型数组字段的文档,因为此类字段需完成大量处理才能进行搜索和索引。

  • 优化索引并删除未使用或效率低下的索引。索引过多会对写入性能产生负面影响。

  • 考虑性能优化顾问具有最高 Impact 和最低 Average Query Targeting 分数的建议索引。

  • 当它们符合您的索引策略时,创建 Performance Advisor 建议的索引。

  • The Performance Advisor can't suggest indexes for MongoDB databases configured to use the ctime timestamp format. As a workaround, set the timestamp format for such databases to either iso8601-utc or iso8601-local.

  • 执行滚动索引构建,以减少构建索引对副本集和分片的集群的性能影响。

  • 删除未使用、多余和隐藏的索引,从而提高写入性能并释放存储空间。