Docs 菜单
Docs 主页
/
MongoDB Cloud Manager
/ / / /

获取建议索引

在此页面上

  • Resource
  • 请求路径参数
  • 请求查询参数
  • 请求正文参数
  • 响应
  • 请求示例
  • 响应示例
  • 响应标头
  • 响应体

检索由Performance Advisor确定的建议索引。

基本URL: 云1.0

GET /groups/{PROJECT-ID}/hosts/{HOST-ID}/performanceAdvisor/suggestedIndexes
Parameter
类型
说明
PROJECT-ID
字符串
(必需。) 拥有此 MongoDB 进程的项目的唯一标识符。
HOST-ID
字符串
(必需。) MongoDB 进程的主机的唯一标识符。

所有参数都是可选的。

pretty
布尔
false
envelope
布尔
指示是否要将响应封装在信封中。
false
since
long
检索建议索引的时间点,以 纪元以来的毫秒数 表示
前24小时
duration
long
在集群托管命名空间中查找建议索引的时间长度(以毫秒为单位)。
截至目前
namespaces
字符串

要从中检索建议索引的命名空间。 命名空间由由.分隔的数据库和集合资源组成,例如<database>.<collection>

要指定多个命名空间,请使用与符号 ( & ) 作为分隔符多次传递参数,每个命名空间一次。

例如:

?namespaces=data.stocks&namespaces=data.zips&pretty=true
所有
nIndexes
long
建议的最大索引数。
无限制
nExamples
long
将通过建议的索引改进的最大示例查询数。
5

此端点不使用 HTTP 请求正文参数。

名称
类型
说明
shapes
文档数组
包含有关建议索引所服务的查询结构的信息的文档。
shapes[n].avgMs
数字
与此形状匹配的已检查查询的平均持续时间(以毫秒为单位)。
shapes[n].count
数字
已检查的与此形状匹配的查询数量。
shapes[n].id
ObjectId
此形状的唯一 ID。 仅在 API 请求期间存在。
shapes[n].inefficiencyScore
数字
查询返回的每个文档的平均读取文档数。 有关详细信息,请参阅了解查询低效率分数。
shapes[n].namespace
字符串
此结构中的查询搜索的命名空间。
shapes[n].operations
文档数组
包含针对各个查询的特定信息和日志行的文档。
shapes[n].operations[n].predicates
文档数组
包含查询使用的Atlas Search条件的文档。 键值对中的值将在这些谓词中进行编辑,除非用户具有“项目数据访问只读”权限或更高权限。
shapes[n].operations[n].raw
字符串
查询生成的原始日志行。
shapes[n].operations[n].stats
文档
查询统计信息。
shapes[n].operations[n].stats.ms
数字
查询的持续时间(以毫秒为单位)。
shapes[n].operations[n].stats.nReturned
数字
查询返回的结果数。
shapes[n].stats.avgObjSize
数字
平均对象大小。
shapes[n].stats.nScanned
数字
查询读取的文档数。
shapes[n].stats.ts
数字
查询时间戳,以自纪元以来的秒数为单位。
suggestedIndexes
文档数组
包含Performance Advisor建议的索引信息的文档。
suggestedIndexes[n].id
ObjectId
此建议索引的唯一 ID。
suggestedIndexes[n].impact
objectId大量

与此响应中与此建议索引相关的查询形状相对应的唯一标识符列表。

此字段与Performance Advisor用户界面中的 Impact不对应。

suggestedIndexes[n].index
文档数组

每个数组元素都是一个文档,指定索引中的键及其排序顺序(升序或降序)。

  • 值为1表示升序排序顺序。

  • 值为 - 1表示降序排序。

具有多个键的索引中的键的显示顺序与其在索引中的显示顺序相同。

suggestedIndexes[n].index.<fieldname>
字符串
要索引的特定字段。
suggestedIndexes[n].namespace
字符串
建议索引的命名空间。
suggestedIndexes[n].weight
数字
建议的索引将提供的预计性能改进。 对应于 用户界面中的 影响 Performance Advisor
curl --user '{PUBLIC-KEY}:{PRIVATE-KEY}' --digest \
--header 'Accept: application/json' \
--include \
--request GET 'https://{OPSMANAGER-HOST}:{PORT}/api/public/v1.0/groups/{PROJECT-ID}/hosts/{HOST-ID}/performanceAdvisor/suggestedIndexes?pretty=true'
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=ISO-8859-1
Date: {dateInUnixFormat}
WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="{nonce}", algorithm=MD5, op="auth", stale=false
Content-Length: {requestLengthInBytes}
Connection: keep-alive
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Type: application/json
Strict-Transport-Security: max-age=300
Date: {dateInUnixFormat}
Connection: keep-alive
Content-Length: {requestLengthInBytes}
X-MongoDB-Service-Version: gitHash={gitHash}; versionString={ApplicationVersion}
{
"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
} ]
}

后退

获取慢查询日志