planCacheListQueryShapes

在本页面

Definition

  • planCacheListQueryShapes
    • 2.6 版的新功能。

显示query shapes,该query shapes存在针对集合的缓存查询计划。

查询优化器仅缓存那些具有多个可行计划的查询形状的计划。

mongo shell 为此命令提供了包装器PlanCache.listQueryShapes()

该命令具有以下语法:

db.runCommand(
   {
      planCacheListQueryShapes: <collection>
   }
)

planCacheListQueryShapes命令具有以下字段:

FieldTypeDescription
planCacheListQueryShapesstring集合的名称。
Returns:包含query shapes数组的文档,对于该数组存在缓存的查询计划。

Required Access

在运行authorization的系统上,用户必须具有包括planCacheRead操作的访问权限。

Example

以下内容返回已缓存orders集合计划的query shapes

db.runCommand(
   {
      planCacheListQueryShapes: "orders"
   }
)

该命令返回包含字段shapes的文档,该字段包含当前在缓存中的query shapes的数组。在此示例中,orders集合已缓存与以下形状关联的查询计划:

{
  "shapes" : [
     {
       "query" : { "qty" : { "$gt" : 10 } },
        "sort" : { "ord_date" : 1 },
        "projection" : { }
     },
     {
        "query" : { "$or" : [ { "qty" : { "$gt" : 15 } }, { "status" : "A" } ] },
        "sort" : { },
        "projection" : { }
     },
     {
       "query" : { "$or" :
          [
            { "qty" : { "$gt" : 15 }, "item" : "xyz123" },
            { "status" : "A" }
          ]
        },
        "sort" : { },
        "projection" : { }
      }
   ],
   "ok" : 1
}