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

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Query Optimization

      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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            8 Vote for this issue
            Watchers:
            31 Start watching this issue

              Created:
              Updated:
              Resolved: