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

Query plan cache key not unique to query shape

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.6.0-rc0
    • 2.6.0-rc1
    • Querying
    • Fully Compatible
    • ALL

    Description

      The query shape serialization mechanism will map distinct query shapes to the same plan cache key. This can cause cache thrashing for the plan cache.

      The encoding of plan cache keys for queries needs to (1) group lists, (2) perform escaping, and (3/4) delimit the query/sort/projection sections. See examples below.

      // 1.
      db.foo.find({$or:[{a:1},{b:1},{c:1}],d:1}) // plan cache key = anoreqaeqbeqceqd
      db.foo.find({$or:[{a:1},{b:1}],c:1,d:1})   // plan cache key = anoreqaeqbeqceqd
       
      // 2.
      db.foo.find({a:1,b:1,c:1}) // plan cache key = aneqaeqbeqc
      db.foo.find({a:1,beqc:1})  // plan cache key = aneqaeqbeqc 
       
      // 3.
      db.foo.find({a:1},{a:NumberInt(1)}) // plan cache key = eqap1a
      db.foo.find({ap1a:1})               // plan cache key = eqap1a
       
      // 4.
      db.foo.find({a:1}).sort({b:1}) // plan cache key = eqaab
      db.foo.find({aab:1})           // plan cache key = eqaab

      Attachments

        Issue Links

          Activity

            People

              benety.goh@mongodb.com Benety Goh
              rassi J Rassi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: