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

MongoDB query planner replanning frequently for _id based sort queries

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.23
    • Component/s: None
    • None
    • Query Optimization
    • ALL

      Based on the logs collected, mongodb query planner seems to be doing replanning several times. 

      The logs show that the query where there is either a match or a sort operation on the _id field causing mongodb query planner to do replan. Here is the sample log:

      planSummary: IXSCAN { _id: "hashed" } cursorid:23334124130458 keysExamined:205 docsExamined:101 fromMultiPlanner:1 replanned:1 replanReason:"cached plan was less efficient than expected: expected trial execution to take 4 works but it took at least 40 works" numYields:9

      This is sometime causing heavy CPU utilisation on MongoDB server with many such queries getting into the replanned stag. Can someone from MongoDB confirm if this is a known behaviour where query or sort based on the _id? This is also seen when the mongodb has multiple indexes matching to the query and _id is one of the either for the sort or match part.

            Assignee:
            nicholas.zolnierz@mongodb.com Nicholas Zolnierz
            Reporter:
            atish.andhare@moengage.com Atish Andhare
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: