[SERVER-16709] Reduce work done for $push:{$each: empty array} Created: 02/Jan/15  Updated: 06/Dec/22  Resolved: 26/Nov/18

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.8.0-rc3
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Participants:

 Description   

db.a.update({_id:1}, {$push:{a:{$each:[]}}}, {upsert:1}) //creates a field
db.a.update({_id:1}, {$push:{a:{$each:[]}}}, {upsert:1}) // produces oplog entry
db.a.update({_id:1}, {$push:{a:{$each:[2,3]}}})
db.a.update({_id:1}, {$push:{a:{$each:[]}}}) // no oplog entry



 Comments   
Comment by Asya Kamsky [ 26/Nov/18 ]

I think this was fixed as of 3.6 update rewrite:

db.a.update({_id:1}, {$push:{a:{$each:[]}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })

Comment by Asya Kamsky [ 28/Jun/17 ]

The other issue is we get:

db.a.update({_id:1}, {$push:{a:{$each:[]}}}) 
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

when nothing should have been modified.

Generated at Thu Feb 08 03:42:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.