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

Update command: unexpected performance

    • Type: Icon: Question Question
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.5
    • None

      I have a strange behavior related to the update command. The execution time is quite different if the collection has indexes or not.

      I have a document like this:
      {
      "data1": 1,
      "array1": [

      { "a": "1a", "b": "1b" }

      ,

      { "a": "2a", "b": "2b" }

      ]
      }

      If I execute an update like this (to add a field) in 10000 elements collection:
      db.collupdate({},{$set:{data2: 1}},

      {multi:true}

      )

      It takes:
      nscanned:10011 nmoved:16 nupdated:10000 keyUpdates:0 numYields: 37 locks(micros) w:24836011 16787ms

      If I create an index on field "array1.a" and repeat the same test, the result is quite different:
      nscanned:10009 nmoved:9 nupdated:10000 keyUpdates:0 numYields: 1384 locks(micros) w:365091225 184838ms

      Why the index is affecting so much? I don't understand why if the index is not defined on that field is affecting in the time execution.

      Thanks a lot

      Raul

            Assignee:
            Unassigned Unassigned
            Reporter:
            raul.diaz_rodriguez@alcatel-lucent.com Raul Diaz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: