- Reference >
- Database Commands >
- Query Plan Cache Commands >
- planCacheClearFilters
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.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:
The
planCacheClearFilters
command has the following field:Field Type Description planCacheClearFilters
string The name of the collection. query
document 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 usingplanCacheListFilters
.sort
document Optional. The sort associated with the filter to remove, if any. projection
document Optional. The projection associated with the filter to remove, if any. comment
any Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:
- mongod log messages, in the
attr.command.cursor.comment
field. - Database profiler output, in the
command.comment
field. currentOp
output, in thecommand.comment
field.
A comment can be any valid BSON type (string, integer, object, array, etc).
New in version 4.4.
- mongod log messages, in the
Required Access¶
A user must have access that includes the
planCacheIndexFilter
action.
Examples¶
Clear Specific Index Filter on Collection¶
The orders
collection contains the following two filters:
The following command removes the second index filter only:
Because the values in the query
predicate are insignificant in
determining the query shape, the following command would also
remove the second index filter:
Clear all Index Filters on a Collection¶
The following example clears all index filters on the orders
collection:
See also