couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthieu Rakotojaona <>
Subject Compaction
Date Thu, 08 Mar 2012 19:21:14 GMT
Hello everyone,

I discovered couchDB a few months ago, and decided to dive in just
recently. I don't want to be long, but couchDB is Amazing. True offline
mode/replication, JSON over HTTP, MVCC, MapReduce and other concepts
widened my horizon of how to solve a problem, and I'm really grateful.

There is a point though that I find sad : the documentation available on
the interwebs are somewhat scarce. Sure you can find yourself because
couchDB is so easy, but there's a particular point that I found to be
especially undocumented : compaction.

Basically all I could find was :
* If you want to compact your db :
	> POST /db/_compact
* If you want to compact your design :
	> POST /db/_compact/designname
	(which seems to say that you can only compact all your views at once
	or none, but not a particular one)
* Although specially designed like that, the absence of automatic
  compaction is seen as unneeded, and a number of people run it with
  cron jobs
* The real effect of a compaction (ie the real size you are going to
	earn) seems to be unknown by many people. Someone (I don't remember
	your name, but thank you) came with a patch to dispaly the data_size,
	which is the real size of your data on disk; this looks hackish.

And the initial purpose to my mail comes here. I just added a few
documents in my db (1.7+M) and found that the disk_size gives me ~2.5GB.
while the data_size is around 660 Mo. From what I read, a compaction is
supposed to leave you with data_size ~= disk_size; yet, after numerous
compaction, it doesn't shrink a bit.

I suppose the problem is exactly the same with views; I'm building it at
the moment, so I will test it later.

I also would like to understand the process of compaction. All I could
see was :

1. couchdb parses the entire DB, fetching only the last (or the few
	 last, from parameters) revision of each document
2. it assembles them in a db.compact.couch file
3. when finished, db.compact.couch replaces db.couch

So I wondered :
* Can you launch a compaction, halt it and continue it later ?
* If yes, can you move the temporary db.compact.couch file somewhere
	else and link to it so that couchdb thinks nothing has changed ?

Thank you,


View raw message