Auto-Create Indexes for Serverless Instances
On this page
Atlas can automatically create indexes for your Serverless instance to improve query performance.
How Auto-Index Creation Works
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.
Auto-Index Creation Frequency
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.
Enable or Disable Auto-Index Creation
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.
Enable Auto-Index Creation
To enable auto-index creation for your Serverless instance with the Atlas UI, complete the following steps:
In Atlas, go to the Clusters page for your project.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
If it's not already displayed, click Clusters in the sidebar.
The Clusters page displays.
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.
Disable Auto-Index Creation
To disable auto-index creation for your Serverless instance with the Atlas UI, complete the following steps:
In Atlas, go to the Clusters page for your project.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
If it's not already displayed, click Clusters in the sidebar.
The Clusters page displays.
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.
Review Automatically Created 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.
Drop Automatically Created Indexes
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.