title: Why do my CouchDB databases grow so fast?
body: <p>I was wondering why my CouchDB database was growing to fast so I wrote a little <a href="https://github.com/konrad/couchdb-benchmarking" rel="nofollow noreferrer">test script</a>. This script changes an attributed of a CouchDB document 1200 times and takes the size of the database after each change. After performing these 1200 writing steps the database is doing a <a href="https://web.archive.org/web/20170112173232/https://wiki.apache.org/couchdb/Compaction" rel="nofollow noreferrer">compaction step</a> and the db size is measured again. In the end the script plots the databases size against the revision numbers. The benchmarking is run twice:</p>
  
  <ul>
  <li>The first time the default number of document revision (=1000) is used (<a href="https://web.archive.org/web/20161012132811/http://wiki.apache.org:80/couchdb/HTTP_database_API#Accessing_Database-specific_options" rel="nofollow noreferrer">_revs_limit</a>).</li>
  <li>The second time the number of document revisions is set to 1.</li>
  </ul>
  
  <p>The first run produces the following plot</p>
  
  <p><a href="https://i.stack.imgur.com/K41QP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K41QP.png" alt="first run"></a>
  </p>
  
  <p>The second run produces this plot</p>
  
  <p><a href="https://i.stack.imgur.com/yR9xy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yR9xy.png" alt="second run"></a>
  </p>
  
  <p>For me this is quite an unexpected behavior. In the first run I would have expected a linear growth as every change produces a new revision. When the 1000 revisions are reached the size value should be constant as the older revisions are discarded. After the compaction the size should fall significantly. </p>
  
  <p>In the second run the first revision should result in certain database size that is then keeps during the following writing steps as every new revision leads to the deletion of the previous one. </p>
  
  <p>I could understand if there is a little bit of overhead needed to manage the changes but this growth behavior seems weird to me. Can anybody explain this phenomenon or correct my assumptions that lead to the wrong expectations?  </p>