Docs Menu
Docs Home
/
MongoDB Manual
/ / /

planCacheListFilters

On this page

  • Definition
  • Compatibility
  • Syntax
  • Command Fields
  • Required Access
  • Output
planCacheListFilters

Lists the index filters associated with plan cache query shapes for a collection.

Returns:Document listing the index filters. See Output.

Starting in MongoDB 8.0, use query settings instead of adding index filters. Index filters are deprecated starting in MongoDB 8.0.

Query settings have more functionality than index filters. Also, index filters aren't persistent and you cannot easily create index filters for all cluster nodes. To add query settings and explore examples, see setQuerySettings.

This command is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Important

This command is not supported in M0, M2, and M5 clusters. For more information, see Unsupported Commands.

The command has the following syntax:

db.runCommand(
{
planCacheListFilters: <collection>
}
)

The command has the following fields:

Field
Type
Description

planCacheListFilters

string

The name of the collection.

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:

A comment can be any valid BSON type (string, integer, object, array, etc).

A user must have access that includes the planCacheIndexFilter action.

The planCacheListFilters command returns the document with the following form:

{
"filters" : [
{
"query" : <query>
"sort" : <sort>,
"projection" : <projection>,
"collation" : <collation>,
"indexes" : [
<index1>,
...
]
},
...
],
"ok" : 1
}
planCacheListFilters.filters

The array of documents that contain the index filter information.

Each document contains the following fields:

planCacheListFilters.filters.query

The query predicate associated with this filter. Although the query shows the specific values used to create the index filter, the values in the predicate are insignificant; i.e. query predicates cover similar queries that differ only in the values.

For instance, a query predicate of { "type": "electronics", "status" : "A" } covers the following query predicates:

{ type: "food", status: "A" }
{ type: "utensil", status: "D" }
planCacheListFilters.filters.sort

The sort associated with this filter. Can be an empty document.

planCacheListFilters.filters.projection

The projection associated with this filter. Can be an empty document.

planCacheListFilters.filters.collation

The collation associated with this filter. Can be an empty document.

planCacheListFilters.filters.indexes

The array of indexes for the plan cache query shape.

The plan cache query shape is the combination of these fields:

To choose the best query plan, the query optimizer evaluates the indexes and the collection scan.

planCacheListFilters.ok

The status of the command.

Tip

See also:

Back

planCacheClearFilters