Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9576

Docs for SERVER-12858: Return detailed stats from write commands

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      Engineering Ticket Description:

      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:
            Unassigned Unassigned
            Reporter:
            emily.hall Emily Hall
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              6 years, 20 weeks, 6 days ago