Avoid reading target node multiple times in $addToSet with arrays

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0, 8.0.29
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • v8.0
    • QE 2026-02-02
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Running an update operation using
       

      {
        findAndModify: "coll",
        query: {_id: 1},
        remove: false,
        new: false,
        upsert: true,
        update: {
          $addToSet: {
            values: {$each: [value1, value2 ... value600]},
          },
        },
      }

       
      will check each value in the array against the entire current content (see addToSet)

      This doesn't scale and cause higher contention rate with similar operations occurring on the same object

            Assignee:
            Ivan Fefer
            Reporter:
            Alberto Massari
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: