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

sort component of internal plan cache key syntax is ambiguous

    • Fully Compatible
    • ALL
    • Quint Iteration 3.1.1

      The internal representation for the sort order of a plan cache key as defined in canonical_query.cpp:269-276 is ambiguous because it does not use any separators for multiple keys.

      These two queries produce the same cache key and could therefore incorrectly use a wrong cached plan:

      db.coll.find( {a: {$gt: 1}, b:1} ).sort( {a:1, b:1} )
      db.coll.find( {a: {$gt: 1}, b:1} ).sort( {aab:1} )
      

      Both produce the internal key: an[eqb,gta]~aaab.

      This could be avoided with a separator between multiple sort keys, e.g.

      an[eqb,gta]~aaab
      an[eqb,gta]~aa,ab
      

            Assignee:
            james.wahlin@mongodb.com James Wahlin
            Reporter:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: