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

Return detailed stats from write commands

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Query Execution
    • Minor Change

      The new commands for insert, delete and update currently only return the total number of documents deleted and modified.

      This significantly reduces the utility of batching since it is impossible for the user to now what actually happened for each update and delete that leads to users falling back to not batching the updates and deletes which negates the purpose of the command in the first place.

      Simply adding an array to the output for the delete and update containing the details for each operation similar to the following will allow users to use the batching commands: (cribbing from the docs)

      db.runCommand(
         {
            delete: "orders",
            deletes: [
               { q: { status: "D" }, limit: 0 },
               { q: { cust_num: 99999, item: "abc123", status: "A" }, limit: 1 }
            ],
            ordered: false,
            writeConcern: { w: 1 }
         }
      )
      { 
         "ok" : 1, 
         "n" : 21
         "deletes" : [ 21, 0 ]
      }
      

      In this example we see that the single delete did not actually delete any documents. It is easy to imagine a situation where that may be important.

      db.runCommand(
         {
            update: "users",
            updates: [
               { q: { status: "P" }, u: { $set: { status: "D" } }, multi: true },
               { q: { _id: 5 }, u: { _id: 5, name: "abc123", status: "A" }, upsert: true }
            ],
            ordered: false,
            writeConcern: { w: 1 }
         }
      )
      {
         "ok" : 1,
         "nDocsModified" : 10,
         "n" : 11,
         "upserted" : [
            {
               "index" : 1,
               "_id" : 5
            }
         ]
         "modified" : [ 10, 1 ]
      }
      

      In this case we could have already determined that the first update had modified 10 documents since the second happened to be an upsert. In general this will not be the case.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            robert.j.moore@allanbank.com Robert Moore
            Votes:
            1 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: