[DOCS-9576] Docs for SERVER-12858: Return detailed stats from write commands Created: 05/Dec/16  Updated: 27/Oct/23  Resolved: 08/Dec/17

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Emily Hall Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: commands, delete-docs-tickets, write
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 6 years, 9 weeks, 5 days ago

 Description   

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.



 Comments   
Comment by Kay Kim (Inactive) [ 08/Dec/17 ]

Opened too soon.

Generated at Thu Feb 08 07:58:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.