planCacheClearFilters

On this page本页内容

Definition定义

planCacheClearFilters

Removes index filters on a collection. 删除集合上的索引筛选器Although index filters only exist for the duration of the server process and do not persist after shutdown, you can also clear existing index filters with the planCacheClearFilters command.尽管索引筛选器仅在服务器进程期间存在,并且在关闭后不会持续存在,但您也可以使用planCacheClearFilters命令清除现有索引筛选器。

Specify the query shape to remove a specific index filter. 指定要删除特定索引筛选器的查询形状。Omit the query shape to clear all index filters on a collection.省略查询形状以清除集合上的所有索引筛选器。

The command has the following syntax:该命令具有以下语法:

db.runCommand(
   {
      planCacheClearFilters: <collection>,
      query: <query pattern>,
      sort: <sort specification>,
      projection: <projection specification>,
      comment: <any>
   }
)

The planCacheClearFilters command has the following field:planCacheClearFilters命令具有以下字段:

Field字段Type类型Description描述
planCacheClearFiltersstringThe name of the collection.集合的名称。
querydocument

Optional. 可选。The query predicate associated with the filter to remove. 与要删除的筛选器关联的查询谓词。If omitted, clears all filters from the collection.如果省略,则清除集合中的所有筛选器。

The values in the query predicate are insignificant in determining the query shape, so the values used in the query need not match the values shown using planCacheListFilters.query谓词中的值在确定查询形状时无关紧要,因此查询中使用的值不必与使用planCacheListFilters显示的值匹配。

sortdocumentOptional. 可选。The sort associated with the filter to remove, if any.与要删除的筛选器关联的排序(如果有)。
projectiondocumentOptional. 可选。The projection associated with the filter to remove, if any. 与要删除的筛选器关联的投影(如果有)。
commentany

Optional. 可选。A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:用户提供了附加到此命令的注释。设置后,此注释将与此命令的记录一起显示在以下位置:

A comment can be any valid BSON type(string, integer, object, array, etc).注释可以是任何有效的BSON类型(字符串、整数、对象、数组等)。

New in version 4.4.在版本4.4中新增

Required Access所需访问权限

A user must have access that includes the planCacheIndexFilter action.用户必须具有包含planCacheIndexFilter操作的访问权限。

Examples示例

Clear Specific Index Filter on Collection清除集合上的特定索引筛选器

The orders collection contains the following two filters:orders集合包含以下两个筛选器:

{
  "query" : { "status" : "A" },
  "sort" : { "ord_date" : -1 },
  "projection" : { },
  "indexes" : [ { "status" : 1, "cust_id" : 1 } ]
}
{
  "query" : { "status" : "A" },
  "sort" : { },
  "projection" : { },
  "indexes" : [ { "status" : 1, "cust_id" : 1 } ]
}

The following command removes the second index filter only:以下命令仅删除第二个索引筛选器:

db.runCommand(
   {
      planCacheClearFilters: "orders",
      query: { "status" : "A" }
   }
)

Because the values in the query predicate are insignificant in determining the query shape, the following command would also remove the second index filter:由于query谓词中的值在确定查询形状时无关紧要,因此以下命令还将删除第二个索引筛选器:

db.runCommand(
   {
      planCacheClearFilters: "orders",
      query: { "status" : "P" }
   }
)

Clear all Index Filters on a Collection清除集合上的所有索引筛选器

The following example clears all index filters on the orders collection:以下示例清除orders集合上的所有索引筛选器:

db.runCommand(
   {
      planCacheClearFilters: "orders"
   }
)
Tip提示
←  planCacheClearplanCacheListFilters →