incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damien Katz <damienk...@gmail.com>
Subject Re: Compaction of new database
Date Mon, 07 Jul 2008 20:08:13 GMT
On Jul 7, 2008, at 2:56 PM, Jan Lehnardt wrote:

>
> On Jul 7, 2008, at 20:38, Brad King wrote:
>
>> Maybe I don't understand compaction, but based on what I've read this
>> is meant to get rid of old doc versions, and essentially any
>> fragmentation that has occurred. What I'm seeing is for a brand new
>> database, I create approximately 300K documents and the size is  
>> 2.2GB.
>> I then run a compact from Futon, and size drops to 414MB. Since this
>> is a new database, which should only have one version of each
>> document, why the dramatic size change?
>
> CouchDB trades disk space for read and write-speed as well. Not only
> for consistency and having old revisions around. When you bulk insert
> all docs, or a bunch of docs at a time, you see less usage than when
> you do single inserts.

Correct. The wasted disk space are small bits of the internal indexes,  
each time you update the database there will be old index data taking  
up space. The amount of space wasted is a function (O(log n)) of the  
total number of documents in the database, regardless if its one  
document being saved, or 1000. Using bulk insert helps reduce the  
wasted space. And compaction will eliminate it completely.

-Damien

>
>
> Cheers
> Jan
> --


Mime
View raw message