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

Explain the UPDATE stage

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • Query Execution

    Description

      When you explain an update command, it only shows how the query part is executed; it doesn't show anything about the update part.

      > db.c.explain().findAndModify({_id: 123}, [{$set:{x:45}}], {upsert:true})
      {
      	"queryPlanner" : {
      		"plannerVersion" : 1,
      		"namespace" : "test.c",
      		"indexFilterSet" : false,
      		"winningPlan" : {
      			"stage" : "UPDATE",
      			"inputStage" : {
      				"stage" : "IDHACK"
      			}
      		},
      		"rejectedPlans" : [ ]
      	},
      	"serverInfo" : {
      		"host" : "dpercy-desktop",
      		"port" : 27017,
      		"version" : "4.5.0-970-g847dfa3",
      		"gitVersion" : "847dfa31a717d9e57028de7cd39e45dc15d3b405"
      	},
      	"ok" : 1
      }
      

      I think the UPDATE stage should include information like:

      • how the [{$set: {x: 45}}] pipeline is represented
      • whether it's a multi-update
      • whether it's an upsert
      • which version of the updated document will be returned (new, old, or none)

      Also, if possible:

      • which indexes will need updating

      This last item could be helpful for deciding whether you have too many indexes. If an update is slow, you .explain() it and see all the indexes that are slowing it down.

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: