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

Push delete limit to underlying find query

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

      When we add a limit to a deletion, it is not passed to underlying find.

      It may lead to wasted work spent multi-planning, because it won't terminate after finding the required number of documents.

      Repro:

      db.test.drop();
      for (let i = 0; i < 10; ++i) {
          db.test.insertOne({a: i, b: i});
      }
      db.test.createIndex({a: 1});
      db.test.createIndex({b: 1});print(db.runCommand({explain: {
          delete: "test",
          deletes: [
              {q: {
                  a: {$gte: 2},
                  b: {$gte: 2}},
                  limit: 1}
          ]}})); 

      Note that we fetch 8 documents instead of just one.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: