Why does similar query takes less execution time evenafter PlanCache().clear

I would like to monitor performance of queries.But,cache will not give true performance.
therefore, I would like to clear cache before executing similar query.

I have clear PlanCache using

and verified null cache using

Even after, why similar query consumes very less execution time?

Hi :wave: @Monika_Shah,

Welcome to the MongoDB Community :sparkles:

Please note that clearing the plan cache does not remove documents and data from other caches such as the filesystem and WT. Instead, it simply removes existing entries from the cache. Upon running new queries, new entries may be added. This is because the PlanCache serves as a cache for the query planner which picks all candidate indexes and then runs queries using them to score which is most efficient and then adds its choice of the best index to the PlanCache again.

Could you please provide more details on what you mean by a “similar query” in this context? Are you asking about why a query is running faster instead of slow, also what metric are you trying to obtain?


I’m guessing that the plan caching is just a small contributor of the overall execution time. the major deciding factor might be if the working set is entirely in RAM and how many disk blocks are to be read and seek and blabla…

So deleting the plan cache doesn’t mean a lot.

Cache memory is double the Database size.