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

[CQF] Investigate optimization failure when hinting with projection

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Optimization
    • QO 2023-02-06, QO 2023-02-20, QO 2023-03-06

      The following query results in an optimization failure:

       > db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceBonsai"})
      { "was" : "tryBonsai", "ok" : 1 }
       > db.foo.drop()
      true
       > db.foo.insert({a: 1})
      WriteResult({ "nInserted" : 1 })
       > db.foo.createIndex({a: 1})
      {
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "createdCollectionAutomatically" : false,
              "ok" : 1
      }
       > db.foo.find({}, {a: 1}).hint({a: 1})
      Error: error: {
              "ok" : 0,
              "errmsg" : "Optimization failed.",
              "code" : 6808706,
              "codeName" : "Location6808706"
      }
       > db.foo.find({a: 1}, {a: 1}).hint({a: 1})
      { "_id" : ObjectId("6364141d2262a3abfef2fb2e"), "a" : 1 }
      

      So, we see an optimization failure when the query just has a projection, but the query succeeds when it has a filter and a projection.

      This behavior is only visible when the hint is present, otherwise both queries succeed (they both choose a physical scan).

            Assignee:
            matt.boros@mongodb.com Matt Boros
            Reporter:
            hana.pearlman@mongodb.com Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: