Docs Menu
Docs Home
/
MongoDB Atlas
/ /

Auto-Create Indexes for Serverless Instances

On this page

  • How Auto-Index Creation Works
  • Enable or Disable Auto-Index Creation
  • Review Automatically Created Indexes
  • Drop Automatically Created Indexes

Atlas can automatically create indexes for your Serverless instance to improve query performance.

Auto-index creation prioritizes creating indexes with the highest Impact score. Atlas defines impact as the estimated performance improvement that the index would bring.

To learn more about the Impact score and how the Performance Advisor ranks indexes, see Review Index Ranking.

Atlas can auto-create up to four indexes per collection in your Serverless instance.

If auto-index creation is enabled, Atlas checks once per hour for slow queries on your Serverless instance. If there are at least 50 slow queries logged in the last hour, Atlas creates one new index at a time if both of the following criteria are met:

  • Atlas finds high-impact index suggestions.

  • Atlas determines that building a new index won't negatively affect the performance of the Serverless instance. When determining performance impact, Atlas checks concurrent index builds, CPU, memory, and other factors.

Atlas enables auto-indexing for Serverless instances by default. You can manually disable or re-enable auto-index creation with the Atlas UI and the Atlas Administration API. If enabled, auto-index creation applies to all collections in the Serverless instance.

To enable auto-index creation for your Serverless instance with the Atlas UI, complete the following steps:

1
  1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. If it's not already displayed, click Clusters in the sidebar.

    The Clusters page displays.

2
  1. Click the name of the Serverless instance.

  2. Click the Performance Advisor tab.

3

To enable auto-index creation for a Serverless instance, send a POST request to the Set Serverless Auto Indexing endpoint and set the value for the enable query parameter to true.

The following example request enables auto-index creation for a Serverless instance:

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Content-Type: application/json" \
--include \
--request POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/serverless/{clusterName}/performanceAdvisor/autoIndexing?enable=true"

Once you enable auto-index creation, Atlas begins to automatically create any suggested high-impact indexes.

To disable auto-index creation for your Serverless instance with the Atlas UI, complete the following steps:

1
  1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. If it's not already displayed, click Clusters in the sidebar.

    The Clusters page displays.

2
  1. Click the name of the Serverless instance.

  2. Click the Performance Advisor tab.

3

To disable auto-index creation for a Serverless instance, send a POST request to the Set Serverless Auto Indexing endpoint and set the value for the enable query parameter to false.

The following example request disables auto-index creation for a Serverless instance:

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Content-Type: application/json" \
--include \
--request POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/serverless/{clusterName}/performanceAdvisor/autoIndexing?enable=false"

After you disable auto-index creation, Atlas stops automatically creating any suggested high-impact indexes.

Atlas sends an email alert when it creates an index automatically. You can view automatically created indexes from the Atlas UI Indexes view. The Atlas UI shows automatically created indexes with the Auto-Created property.

You can drop auto-created indexes as you would any other index. To drop an auto-created index, click Drop Index. If you drop an auto-created index, auto-index creation doesn't recreate that index. Performance Advisor might still recommend that index.

Back

Configure Backup