Docs Menu
Docs Home
/
MongoDB Manual
/ / /

db.collection.getPlanCache()

On this page

  • Definition
  • Compatibility
  • Methods
db.collection.getPlanCache()

Important

mongosh Method

This is a mongosh method. This is not the documentation for Node.js or other programming language specific driver methods.

In most cases, mongosh methods work the same way as the legacy mongo shell methods. However, some legacy methods are unavailable in mongosh.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

For MongoDB API drivers, refer to the language specific MongoDB driver documentation.

Returns an interface to access the query plan cache for a collection. The interface provides methods to view and clear the query plan cache.

Returns:Interface to access the query plan cache.

The query optimizer only caches the plans for those query shapes that can have more than one viable plan.

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

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

The following methods are available through the interface:

Name
Description
Displays the methods available for a collection's query plan cache. Accessible through the plan cache object of a specific collection, i.e. db.collection.getPlanCache().help().
Clears the cached query plans for the specified query shape. Accessible through the plan cache object of a specific collection, i.e. db.collection.getPlanCache().clearPlansByQuery()
Clears all the cached query plans for a collection. Accessible through the plan cache object of a specific collection, i.e. db.collection.getPlanCache().clear().
Returns the plan cache information for a collection. Accessible through the plan cache object of a specific collection, i.e. db.collection.getPlanCache().list().

Back

Query Plan Caches