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

Plan ranking should take query and index keys into consideration for breaking ties

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Labels:
    • Case:

      Description

      In situation where there are two plans that tie, if one matches more (leading?) keys in the query than another then it's more likely to be a better plan for other queries of this shape.

      Example:

      db.collection.find({a:999, b:111, c:"x"}).sort({d:-1})
      // indexes for collection:
      {a:1,b:1,c:1,d:1}
      {a:1,b:1,d:1}
      {a:1,d:1}
      

      For value of a in query that matches one or no documents all three indexes are going to perform equally (yes?) - we should break the tie in favor of the first one because it matches the most predicate fields in the query.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              asya Asya Kamsky
              Participants:
              Votes:
              3 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated: