Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-64978

Add metrics to track if a plan was recovered from the plan cache

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible

      Currently there is no an easy way to tell if a specific plan has been recovered from the cache or not. The closest match would be to obtain a plan cache key (via explain, slow logs or profiler), find a corresponding plan cache entry with $planCacheStats and see if the cached entry is active or not. If yes, then most likely the plan was recovered from the cache. But this is sort of unreliable way to check it due to a timing window when a plan cache entry has been created and got activated. That is, a plan could be created not from the cache and an inactive cache entry was added to the cache. In the same time a few other queries of a similar shape could be execute, turning the cached plan into active. When the user tries to follow the above procedure to figure out if the first plan was recovered from the cache, they would receive the wrong answer.

      Instead, we should consider adding a new flag similar to fromMultiPlanner which could honestly indicate if the plan has been recovered from the cache.

      On a similar note, it would be very handy to track plan cache hits and misses via serverStatus metrics.

      CC christopher.harris kateryna.kamenieva

            Assignee:
            maddie.zechar@mongodb.com Maddie Zechar
            Reporter:
            anton.korshunov@mongodb.com Anton Korshunov
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: