Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5251

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

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.1.0, 7.3.3
    • Component/s: Query
    • 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@mongodb.com Neil Shweky (Inactive)
            Reporter:
            boaz@honeybook.com Boaz Adato
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: