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

Collection.deleteOne() ignores hint

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • ALL
    • Hide
      (function() {
             "use strict";
      
             const coll = db['deleteone_ignores_hint'];
             coll.drop();
             coll.insertOne({_id:1});
             db.runCommand({delete: coll.getName(), 
                       deletes: [{q: {_id:1}, limit: 1, hint: {$natural:1}}]}); // This uses the hint.
             assert.eq(0, coll.aggregate( [ { $indexStats: { } }]).toArray()[0].accesses.ops);
      
             coll.deleteOne({_id:1},{hint:{$natural:1}}); // This doesn't.
             assert.eq(0, coll.aggregate( [ { $indexStats: { } }]).toArray()[0].accesses.ops)
      })();
      
      Show
      ( function () { "use strict" ; const coll = db[ 'deleteone_ignores_hint' ]; coll.drop(); coll.insertOne({_id:1}); db.runCommand({ delete : coll.getName(), deletes: [{q: {_id:1}, limit: 1, hint: {$natural:1}}]}); // This uses the hint. assert.eq(0, coll.aggregate( [ { $indexStats: { } }]).toArray()[0].accesses.ops); coll.deleteOne({_id:1},{hint:{$natural:1}}); // This doesn't. assert.eq(0, coll.aggregate( [ { $indexStats: { } }]).toArray()[0].accesses.ops) })();

      The method deleteOne() accepts a hint but currently it is ignored, at least when using the $natural parameter.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            daniel.gomezferro@mongodb.com Daniel Gomez Ferro
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: