title: MongoDB optimization
body: <p>I need to optimize my MongoDB performance but can't figure out how. Maybe there's some tips. Or maybe i should use another storage engine. Any ideas are welcome.</p>
  
  <p>I have following log output in which are described query:</p>
  
  <pre><code>2015-08-04T15:09:56.226+0300 [conn129682] command mongodb_db1.$cmd command: aggregate { aggregate: "collection", pipeline: [ { $match: { _id.index_id_1: 4931359 } } ] } keyUpdates:0 numYields:39 locks(micros) r:83489 reslen:177280 286ms
  </code></pre>
  
  <p>I have collection named <em>collection</em> which contains following data structure:</p>
  
  <pre><code>{
    "_id" : {
      "x" : "x",
      "index_id_1" : NumberLong(5617088)
    },
    "value" : {
      "value_1" : 1.0000000000000000,
      "value_2" : 0.0000000000000000,
      "value_3" : 1.0000000000000000
    }
  }
  </code></pre>
  
  <p>By querying stats in result i have following details:</p>
  
  <pre><code> {
    "ns" : "mongodb_db1.collection",
    "count" : 2.07e+007,
    "size" : 4968000000.0000000000000000,
    "avgObjSize" : 240,
    "storageSize" : 5524459408.0000000000000000,
    "numExtents" : 25,
    "nindexes" : 3,
    "lastExtentSize" : 5.36601e+008,
    "paddingFactor" : 1.0000000000000000,
    "systemFlags" : 0,
    "userFlags" : 1,
    "totalIndexSize" : 4475975728.0000000000000000,
    "indexSizes" : {
      "_id_" : 2884043120.0000000000000000,
      "_id.x.index_id_1" : 1.07118e+009,
      "_id.index_id_1" : 5.20754e+008
    },
    "ok" : 1.0000000000000000
  }
  </code></pre>
  
  <ul>
  <li>Running on single node ( no shards ). </li>
  <li>MongoDB version is: 2.4.</li>
  <li>Installed RAM (MB): 24017 ( index size ~120GB )</li>
  </ul>