Docs 菜单

获取模式建议

通过分析 20 最活跃的集合,为集群提供模式改进建议。

基本 URL: https://cloud.mongodb.com/api/public/v 1.0

GET /groups/{PROJECT-ID}/performanceAdvisor/schemaAdvice
Parameter
类型
说明

PROJECT-ID

字符串

(必需。)拥有此MongoDB 部署的项目的唯一标识符。群组和项目是同义词。您的群组 ID(group ID)与您的项目ID相同。

需要 clusterIdhostId

Parameter
类型
说明

pretty

布尔

指示响应正文是否应采用 美观打印 格式。

envelope

布尔

指示是否要将响应封装在信封中。

clusterId

字符串

副本集或分片集群的唯一标识符。如果您需要使用 hostId 为独立运行实例提供模式建议,请将此参数设置为 null

hostId

字符串

您想要模式建议的独立运行实例的唯一标识符。如果 clusterIdnull,则为必填项。

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

名称
类型
说明

content

对象列表

包含针对每个命名空间的模式改进的建议操作。

content.recommendations

对象

包含Performance Advisor模式改进建议的命名空间。

content.recommendations .affectedNamespaces

阵列

命名空间列表以及有关这些命名空间触发建议的原因的信息。

content.recommendations .affectedNamespaces.namespace

字符串

受影响集合的命名空间。这是针对 REDUCE_NUMBER_OF_NAMESPACES 建议的 null

content.recommendations .affectedNamespaces.triggers

对象

有关激活建议的触发的详细信息。

content.recommendations .affectedNamespaces.triggers .description

字符串

触发类型的描述。

content.recommendations .affectedNamespaces.triggers .triggerType

字符串

触发类型。 选项包括:

  • PERCENT_QUERIES_USE_LOOKUP

  • NUMBER_OF_QUERIES_USE_LOOKUP

  • DOCS_CONTAIN_UNBOUNDED_ARRAY

  • NUMBER_OF_NAMESPACES

  • DOC_SIZE_TOO_LARGE

  • NUM_INDEXES

  • QUERIES_CONTAIN_CASE_INSENSITIVE_REGEX

content.recommendations .description

字符串

指定推荐的描述。

content.recommendations .recommendation

字符串

推荐类型。选项包括:

  • REDUCE_LOOKUP_OPS

  • AVOID_UNBOUNDED_ARRAY

  • REDUCE_DOCUMENT_SIZE

  • REMOVE_UNNECESSARY_INDEXES

  • REDUCE_NUMBER_OF_NAMESPACES

  • OPTIMIZE_CASE_INSENSITIVE_REGEX_QUERIES

  • OPTIMIZE_TEXT_QUERIES

curl --user '{PUBLIC-KEY}:{PRIVATE-KEY}' --digest \
--header 'Accept: application/json' \
--include \
--request GET 'https://cloud.mongodb.com/api/public/v1.0/groups/{PROJECT-ID}/performanceAdvisor/schemaAdvice?clusterId={clusterId}&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}
{
"content" : {
"recommendations" : [ {
"affectedNamespaces" : [ {
"namespace" : "someDb.someCollection",
"triggers" : [ {
"description" : "Documents larger than 2 MB found in the collection(s) scanned",
"triggerType" : "DOC_SIZE_TOO_LARGE"
} ]
}, {
"namespace" : "someDb1.someCollection1",
"triggers" : [ {
"description" : "Documents larger than 2 MB found in the collection(s) scanned",
"triggerType" : "DOC_SIZE_TOO_LARGE"
} ]
} ],
"description" : "Reduce the size of documents",
"recommendation" : "REDUCE_DOCUMENT_SIZE"
}, {
"affectedNamespaces" : [ {
"namespace" : "someDb2.someCollection2",
"triggers" : [ {
"description" : "More than 30 indexes detected in the collection(s) scanned",
"triggerType" : "NUM_INDEXES"
} ]
}, {
"namespace" : "someDb3.someCollection3",
"triggers" : [ {
"description" : "More than 30 indexes detected in the collection(s) scanned",
"triggerType" : "NUM_INDEXES"
} ]
} ],
"description" : "Remove unnecessary indexes",
"recommendation" : "REMOVE_UNNECESSARY_INDEXES"
}, {
"affectedNamespaces" : [ {
"namespace" : "someDb4.someCollection4",
"triggers" : [ {
"description" : "Arrays with over 10000 entries detected in the collection(s) scanned",
"triggerType" : "DOCS_CONTAIN_UNBOUNDED_ARRAY"
} ]
} ],
"description" : "Avoid using unbounded arrays in documents",
"recommendation" : "AVOID_UNBOUNDED_ARRAY"
} ]
},
"status" : 200
}