planCacheClearFilters
Definition
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 planCacheClearFilters
command.
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>
- }
- )
The planCacheClearFilters
command has the following field:
FieldTypeDescriptionplanCacheClearFilters
stringThe name of the collection.query
documentOptional. 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
.sort
documentOptional. The sort associated with the filter to remove, if any.projection
documentOptional. 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:
- {
- "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 indetermining the query shape, the following command would alsoremove the second index filter:
- 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:
- db.runCommand(
- {
- planCacheClearFilters: "orders"
- }
- )
See also