About query plan caching

Hi @Kim_Hakseon,

Per the documentation that @steevej referenced, a query plan that is Active can move to an Inactive state in the cache if there is a better performing plan:

The planner also evaluates the entry’s performance and if its works value no longer meets the selection criterion, it will transition to Inactive state.

The query cache is also affected by catalog operations like index changes and collection drops (see: Plan Cache Flushes).

There have been some changes to query plan caching in successive MongoDB versions, so if you are using an older release series of MongoDB please select the relevant version of the manual from the selection drop-down near the top left of the Query Plans page. The description above is applicable to MongoDB 4.2 and 4.4 (which added states for plan cache entries), but all modern versions of MongoDB have a query replanning mechanism.

Regards,
Stennie