db.collection.getPlanCache()

Definition

  • db.collection.getPlanCache()

mongo Shell Method

This page documents the mongo shell method, and doesnot refer to the MongoDB Node.js driver (or any other driver)method. For corresponding MongoDB driver API, refer to your specificMongoDB driver documentation instead.

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

Returns:Interface to access the query plan cache.

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

Methods

The following methods are available through the interface:

NameDescription
PlanCache.help()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().
PlanCache.listQueryShapes()Displays the query shapes for which cached query plans exist.Accessible through the plan cache object of a specific collection,i.e. db.collection.getPlanCache().listQueryShapes().
PlanCache.getPlansByQuery()Displays the cached query plans for the specified query shape.Accessible through the plan cache object of a specific collection,i.e. db.collection.getPlanCache().getPlansByQuery().
PlanCache.clearPlansByQuery()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()
PlanCache.clear()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().