title: Is it 100 million documents too much?
body: <p>Well, I am new to <code>mongo</code> and today morning I had a (bad) idea. I was playing around with indexes from the shell and decided to create a large collection with many documents (100 million). So I executed the following command:</p>
  
  <pre><code>for (i = 1; i &lt;= 100; i++) { 
      for (j = 100; j &gt; 0; j--) { 
          for (k = 1; k &lt;= 100; k++) { 
              for (l = 100; l &gt; 0; l--) {
                  db.testIndexes.insert({a:i, b:j, c:k, d:l})
              }
          }
      }
  }
  </code></pre>
  
  <p>However, the things didn't go as I expected: </p>
  
  <ol>
  <li>It took 45 minutes complete the request.</li>
  <li>It created 16 GB data on my hard disk.</li>
  <li>It used 80% of my RAM (8GB total) and it won't release them till I restarted my PC.</li>
  </ol>
  
  <p>As you can see in the photo below, as the number of documents inside the collection was growing, the time of the insertion of documents was growing as well. I suggest that by the last modification time of the data files:</p>
  
  <p><img src="https://i.stack.imgur.com/80M9z.png" alt="enter image description here"></p>
  
  <p>Is this an expected behavior? I don't think that 100 million <strong>simple</strong> documents are too much.</p>
  
  <p>P.S. I am now really afraid to run an <code>ensureIndex</code> command.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I executed the following command:</p>
  
  <pre><code>&gt; db.testIndexes.stats()
  {
          "ns" : "test.testIndexes",
          "count" : 100000000,
          "size" : 7200000056,
          "avgObjSize" : 72.00000056,
          "storageSize" : 10830266336,
          "numExtents" : 28,
          "nindexes" : 1,
          "lastExtentSize" : 2146426864,
          "paddingFactor" : 1,
          "systemFlags" : 1,
          "userFlags" : 0,
          "totalIndexSize" : 3248014112,
          "indexSizes" : {
                  "_id_" : 3248014112
          },
          "ok" : 1
  }
  </code></pre>
  
  <p>So, the default index on <code>_id</code> has more than 3GB size.</p>