On this page本页内容
planCacheClear
Removes cached query plans for a collection. 删除集合的缓存查询计划。Specify a query shape to remove cached query plans for that shape. 指定查询形状以删除该形状的缓存查询计划。Omit the query shape to clear all cached query plans.省略查询形状以清除所有缓存的查询计划。
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
planCacheClear: <collection>,
query: <query>,
sort: <sort>,
projection: <projection>,
comment: <any>
}
)
The planCacheClear
command has the following field:planCacheClear
命令具有以下字段:
query | document | |
projection | document | |
sort | document | |
comment | any |
|
To see the query shapes for which cached query plans exist, see List Query Shapes.要查看存在缓存查询计划的查询形状,请参阅列出查询形状。
On systems running with 在使用authorization
, a user must have access that includes the planCacheWrite
action.authorization
运行的系统上,用户必须具有包括planCacheWrite操作的访问权限。
If a collection 如果orders
has the following query shape:orders
集合具有以下查询形状:
{ "query" : { "qty" : { "$gt" : 10 } }, "sort" : { "ord_date" : 1 }, "projection" : { }, "queryHash" : "9AAD95BE" // Available starting in MongoDB 4.2 }
The following operation clears the query plan cached for the shape:以下操作将清除为形状缓存的查询计划:
db.runCommand( { planCacheClear: "orders", query: { "qty" : { "$gt" : 10 } }, sort: { "ord_date" : 1 } } )
The following example clears all the cached query plans for the 以下示例清除orders
collection:orders
集合的所有缓存查询计划:
db.runCommand( { planCacheClear: "orders" } )