This topic introduces the index optimization feature of ApsaraDB for MongoDB. If you forget to add indexes or use incorrect indexes, query statements may run slowly or time out. This increases the CPU utilization of your ApsaraDB for MongoDB instance. This feature detects slow queries caused by the index issues, and provides the optimal indexes for these slow queries to improve the performance of ApsaraDB for MongoDB.

Prerequisites

  • The instance is a replica set or sharded cluster instance.
  • The region of the instance is China (Hangzhou), China (Shanghai), China (Shenzhen), China (Qingdao), or China (Beijing).
  • The audit logging feature is enabled for the instance.

Rules to generate an index optimization report

ApsaraDB for MongoDB automatically generates index optimization reports for statements executed from 00:00:00 to 24:00:00 every day. You can also select a time range to generate an index optimization report by using the Custom Analysis function in the ApsaraDB for MongoDB console.

Note
  • Query statements whose execution time exceeds 100 ms are defined as slow queries.
  • Index optimization reports are retained for seven days and are automatically deleted after the seventh day.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the region where the target instance resides.
  3. In the left-side navigation pane, click Replica Set Instances or Sharding Instances.
  4. Find the target instance and click its ID.
  5. In the left-side navigation pane, choose CloudDBA > Index Optimization.
  6. Click Custom Analysis.
  7. In the Custom Analysis dialog box that appears, select a time range and click OK.
  8. Find the index optimization report you want to view, and click View Detail in the Operation column.
  9. In the dialog box that appears, view the index diagnosis details.
  10. Add or optimize indexes based on the details.