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.
- 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.
- 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.
- Log on to the ApsaraDB for MongoDB console.
- In the upper-left corner of the page, select the region where the target instance resides.
- In the left-side navigation pane, click Replica Set Instances or Sharding Instances.
- Find the target instance and click its ID.
- In the left-side navigation pane, choose .
- Click Custom Analysis.
- In the Custom Analysis dialog box that appears, select a time range and click OK.
- Find the index optimization report you want to view, and click View Detail in the Operation column.
- In the dialog box that appears, view the index diagnosis details.
- Add or optimize indexes based on the details.