db.collection.getPlanCache()

On this page本页内容

Definition定义

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.查询优化器只缓存那些可以有多个可行计划的查询形状的计划。

Methods方法

The following methods are available through the interface:通过界面可以使用以下方法:

Name名称Description描述
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().可通过特定集合的计划缓存对象访问,即db.collection.getPlanCache().help()
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()可通过特定集合的计划缓存对象访问,即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().可通过特定集合的计划缓存对象访问,即db.collection.getPlanCache().clear()
PlanCache.list()

Returns the plan cache information for a collection. 返回集合的计划缓存信息。Accessible through the plan cache object of a specific collection, i.e. db.collection.getPlanCache().list().可通过特定集合的计划缓存对象访问,即db.collection.getPlanCache().list()

New in version 4.4.在版本4.4中新增

←  Query Plan Cache MethodsPlanCache.clear() →