Navigation

Get Suggested Indexes

Retrieves any suggested indexes generated by the Atlas Performance Advisor.

Info With Circle IconCreated with Sketch.Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

The Atlas API authenticates using HTTP Digest Authentication. Provide a programmatic API public key and corresponding private key as the username and password when constructing the HTTP request.

To learn how to configure API access for an Atlas project, see Configure Atlas API Access.

https://cloud.mongodb.com/api/atlas/v1.0

GET /groups/{GROUP-ID}/processes/{PROCESS-ID}/performanceAdvisor/suggestedIndexes
Path ElementDescription
GROUP-IDUnique identifier for the project.
PROCESS-IDThe Atlas hostname and port, e.g. m10-shard-00-00-17jcm.mongodb.net:27017. To retrieve all processes in the project with a given GROUP-ID, use the /groups/{GROUP-ID}/processes endpoint.

All parameters are optional.

Path ElementTypeDescription
sincelongPoint in time from which to retrieve suggested indexes, stated in milliseconds since epoch.
durationlongLength of time in milliseconds during which to find suggested indexes among the managed namespaces in the cluster.
namespacesstring

Namespaces from which to retrieve suggested indexes. A namespace consists of the database and collection resource separated by a ., such as <database>.<collection>.

To specify multiple namespaces, pass the parameter multiple times using an ampersand (&) as a delimiter, once for each namespace.

Beaker IconExample

?namespaces=data.stocks&namespaces=data.zips&pretty=true

Omit to return results for all namespaces.

nIndexeslongMaximum number of indexes to suggest. Defaults to unlimited.
nExampleslongMaximum number of examples queries to provide that will be improved by a suggested index. Defaults to 5.
prettybooleanDisplay response in a prettyprint format. Defaults to false.
envelopebooleanSpecifies whether or not to wrap the response in an envelope. Defaults to false.
Info With Circle IconCreated with Sketch.Note

If since is indicated and duration is omitted, the response contains results from the since point up to the present time.

If duration is indicated and since is omitted, the response contains results from duration ms ago through the present time.

If both since and duration are omitted, the response contains results from the previous 24 hours up through the present time.

This endpoint does not use HTTP request body parameters.

NameTypeDescription
shapesarray of documentsDocuments with information about the query shapes that are served by the suggested indexes.
shapes[n].avgMsnumberAverage duration in milliseconds for the queries examined that match this shape.
shapes[n].countnumberNumber of queries examined that match this shape.
shapes[n].idobjectIdUnique id for this shape. Exists only for the duration of the API request.
shapes[n].inefficiencyScorenumberAverage number of documents read for every document returned by the query. For more information, see Understanding the Query Inefficiency Score.
shapes[n].namespacestringNamespace searched by the queries in this shape.
shapes[n].operationsarray of documentsDocuments with specific information and log lines for individual queries.
shapes[n].operations[n].predicatesarray of documentsDocuments containing the search criteria used by the query. Values in key-value pairs will be redacted in these predicates unless the user has Project Data Access Read Only permissions or higher.
shapes[n].operations[n].rawstringRaw log line produced by the query.
shapes[n].operations[n].statsdocumentQuery statistics.
shapes[n].operations[n].stats.msnumberDuration in milliseconds of the query.
shapes[n].operations[n].stats.nReturnednumberNumber of results returned by the query.
shapes[n].stats.nScannednumberNumber of documents read by the query.
shapes[n].stats.tsnumberQuery timestamp, in seconds since epoch.
suggestedIndexesarray of documentsDocuments with information about the indexes suggested by the Performance Advisor.
suggestedIndexes[n].idobjectIdUnique id for this suggested index.
suggestedIndexes[n].impactarray of objectIds

List of unique identifers which correspond the query shapes in this response which pertain to this suggested index.

Info With Circle IconCreated with Sketch.Note

This field does not correspond to Impact in the Performance Advisor user interface.

suggestedIndexes[n].indexarray of documents

Each array element is a document that specifies a key in the index and its sort order, ascending or descending.

  • A value of 1 indicates an ascending sort order.
  • A value of -1 indicates a descending sort order.

Keys in indexes with multiple keys appear in the same order that they appear in the index.

suggestedIndexes[n].index.<fieldname>stringSpecific field to be indexed.
suggestedIndexes[n].namespacestringNamespace of the suggested index.
suggestedIndexes[n].weightnumberEstimated percentage performance improvement that the suggested index would provide. Corresponds to Impact in the Performance Advisor user interface.
suggestedIndexes[n].dismissedFromAutoCreationbooleanIndicates whether this index suggestion was manually dismissed from auto-creation. This field is only present when the value is true.
curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest -i \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--request GET "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/processes/{PROCESS-ID}/performanceAdvisor/suggestedIndexes?namespaces=test.users&namespaces=test.inventory&pretty=true"
{
"shapes" : [ {
"avgMs" : 42,
"count" : 2,
"id" : "5b74689a80eef53f3388897e",
"inefficiencyScore" : 50000,
"namespace" : "test.users",
"operations" : [ {
"predicates" : [{ "find" : { "emails" : "la@sa.kp" } }],
"raw" : "2018-08-15T17:14:11.115+0000 I COMMAND [conn4576] command test.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \"la@sa.kp\" }, lsid: { id: UUID(\"1a4e71d3-9b67-4e9c-b078-9fdf3fae9091\") }, $clusterTime: { clusterTime: Timestamp(1534353241, 1), signature: { hash: BinData(0, AB91938B7CF7BC87994A2909A98D87F29101EFA0), keyId: 6589681559618453505 } }, $db: \"test\" } planSummary: COLLSCAN keysExamined:0 docsExamined:50000 cursorExhausted:1 numYields:391 nreturned:1 reslen:339 locks:{ Global: { acquireCount: { r: 784 } }, Database: { acquireCount: { r: 392 } }, Collection: { acquireCount: { r: 392 } } } protocol:op_msg 34ms",
"stats" : {
"ms" : 34,
"nReturned" : 1,
"nScanned" : 50000,
"ts" : 1534353251147
}
}, {
"predicates" : [{ "find" : { "emails" : "tocde@fijoow.to" } }],
"raw" : "2018-08-15T17:14:18.665+0000 I COMMAND [conn4576] command test.users appName: \"MongoDB Shell\" command: find { find: \"users\", filter: { emails: \"tocde@fijoow.to\" }, lsid: { id: UUID(\"1a4e71d3-9b67-4e9c-b078-9fdf3fae9091\") }, $clusterTime: { clusterTime: Timestamp(1534353241, 1), signature: { hash: BinData(0, AB91938B7CF7BC87994A2909A98D87F29101EFA0), keyId: 6589681559618453505 } }, $db: \"test\" } planSummary: COLLSCAN keysExamined:0 docsExamined:50000 cursorExhausted:1 numYields:390 nreturned:1 reslen:342 locks:{ Global: { acquireCount: { r: 782 } }, Database: { acquireCount: { r: 391 } }, Collection: { acquireCount: { r: 391 } } } protocol:op_msg 36ms",
"stats" : {
"ms" : 36,
"nReturned" : 1,
"nScanned" : 50000,
"ts" : 1534353258697
}
} ]
} ],
"suggestedIndexes" : [ {
"id" : "5b74689a80eef53f3388897f",
"impact" : [ "5b74689a80eef53f3388897e" ],
"index" : [ {
"emails" : 1
} ],
"namespace" : "test.users",
"weight" : 37.220480901815623
}, {
"id" : "5b74689a80eef53f33888980",
"impact" : [ "5b74689a80eef53f3388897d" ],
"index" : [ {
"email" : 1
} ],
"namespace" : "test.inventory",
"weight" : 19.037578309966488
} ]
}
Give Feedback