find(_id) generates useless redundant $and in query causing suboptimal query planning

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 7.1.0, 7.3.3
    • Component/s: Query
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hello

      It seems that since upgrading to mongoid 7.3.3 we're facing unexpected find by id queries being generated by mongoid. According to logs, instead of a simple _{id: ObjectId('...')}

      queries we see "_id $and _id" combined queries, with the same BSON object id used in both.

      According to mongo instance logs, it cause the queries to be IXSCAN as opposed to IDHACK.

      Here's a gist for easy reproducing.

      Thanks
      Boaz

              Assignee:
              Neil Shweky (Inactive)
              Reporter:
              Boaz Adato
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: