user2636123
user2636123

Reputation: 75

Couchdb size management

I have a couch database called restaurants.couch and once a week I would Compact Database and the file size will go from 20MB to 11MB.

I see that the older versions are gone - which I don't need.

However, I notice that the .restaurants_design folder size is over 100MB and there are 30+ .view files in here.

I executed Compact Views and Clean Up Views, and it reduced it to 8MB and to just 1 .view file. My app also ran a little faster.

My questions :

1) Why does .restaurants_design get so large ? What's the reason. It's just a view.

2) What's the benefit of Compact Views and Clean Up Views ( besides file size reduction ) ?

3) What are the side effects of Compact Views and Clean Up Views ? Will I ever regret doing this if I don't need versioning ?

4) How often should Compact Database, Compact Views, and Clean Up Views be performed if the app does not really need versioning other than a simple nosql database with some views.

Upvotes: 2

Views: 548

Answers (1)

Andy
Andy

Reputation: 5414

  1. CouchDb caches the view query result on disk for indexing to speed to the query. So if you have lots of views, and user query them with different parameters, they will be cached.
  2. Compact Views - View indexes on disk are named after their MD5 hash of the view definition. When you change a view, old indexes remain on disk. To clean up all outdated view indexes (files named after the MD5 representation of views, that does not exist anymore) you can trigger a view cleanup:. Clean Up Views however, remove old views caches, since if you update a view, the old result of the view is still on disk.
  3. The side effects is the next person who query the view will take longer time since CouchDB will need to rebuild the caches. Compact Views and Clean Up Views does not effect versioning, but Compact Database does.
  4. The frequency really depend on the way your application work and the limitation of you deployment setup. However if you really want to disable versioning, try look into _revs_limit setting, so you can just set a limit of revision for all documents.

Upvotes: 2

Related Questions