planCacheClearFilters

Definition

  • planCacheClearFilters

New in version 2.6.

Removes index filters on a collection.Although index filters only exist for the duration of the serverprocess and do not persist after shutdown, you can also clearexisting index filters with the planCacheClearFilterscommand.

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:

  1. db.runCommand(
  2. {
  3. planCacheClearFilters: <collection>,
  4. query: <query pattern>,
  5. sort: <sort specification>,
  6. projection: <projection specification>
  7. }
  8. )

The planCacheClearFilters command has the following field:

FieldTypeDescriptionplanCacheClearFiltersstringThe name of the collection.querydocumentOptional. The query predicate associated with the filter to remove. Ifomitted, clears all filters from the collection.

The values in the query predicate are insignificant indetermining the query shape, so the values used in the queryneed not match the values shown usingplanCacheListFilters.sortdocumentOptional. The sort associated with the filter to remove, if any.projectiondocumentOptional. The projection associated with the filter to remove,if any.

Required Access

A user must have access that includes theplanCacheIndexFilter action.

Examples

Clear Specific Index Filter on Collection

The orders collection contains the following two filters:

  1. {
  2. "query" : { "status" : "A" },
  3. "sort" : { "ord_date" : -1 },
  4. "projection" : { },
  5. "indexes" : [ { "status" : 1, "cust_id" : 1 } ]
  6. }
  7.  
  8. {
  9. "query" : { "status" : "A" },
  10. "sort" : { },
  11. "projection" : { },
  12. "indexes" : [ { "status" : 1, "cust_id" : 1 } ]
  13. }

The following command removes the second index filter only:

  1. db.runCommand(
  2. {
  3. planCacheClearFilters: "orders",
  4. query: { "status" : "A" }
  5. }
  6. )

Because the values in the query predicate are insignificant indetermining the query shape, the following command would alsoremove the second index filter:

  1. db.runCommand(
  2. {
  3. planCacheClearFilters: "orders",
  4. query: { "status" : "P" }
  5. }
  6. )

Clear all Index Filters on a Collection

The following example clears all index filters on the orderscollection:

  1. db.runCommand(
  2. {
  3. planCacheClearFilters: "orders"
  4. }
  5. )

See also

planCacheListFilters,planCacheSetFilter