# Automatically compact CouchDB databases in version 0.11.x

DevFeed: [Automatically compact CouchDB databases in version 0.11.x](<https://devfeed.tech/articles/automatically-compact-couchdb-databases-in-version-0-11-x-27549.md>)

Original publisher: [Read original article](<https://gagor.pro/2012/11/automatically-compact-couchdb-databases-in-0-11-x/>)

Author: Tom

Published: 2012-11-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [Tomasz Gągor](<https://devfeed.tech/sources/tomasz-gagor.md>)

Topics: [couchdb](<https://devfeed.tech/topics/couchdb.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [Script](<https://devfeed.tech/topics/script.md>), [Bash](<https://devfeed.tech/topics/bash.md>), [cURL](<https://devfeed.tech/topics/curl.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [JSON](<https://devfeed.tech/topics/json.md>)

Tags: [bash](<https://devfeed.tech/tags/bash.md>), [couchdb](<https://devfeed.tech/tags/couchdb.md>), [curl](<https://devfeed.tech/tags/curl.md>), [daily](<https://devfeed.tech/tags/daily.md>), [databases](<https://devfeed.tech/tags/databases.md>), [http](<https://devfeed.tech/tags/http.md>), [json](<https://devfeed.tech/tags/json.md>), [linux](<https://devfeed.tech/tags/linux.md>), [performance](<https://devfeed.tech/tags/performance.md>), [post](<https://devfeed.tech/tags/post.md>), [script](<https://devfeed.tech/tags/script.md>)

## AI overview

This tutorial presents a Bash script that can run from cron to compact all CouchDB databases on version 0.11.x. It states that regular compaction helps manage database growth, performance, and space usage.

## Source excerpt

CouchDB databases on version 0.11.x swell very fast. They should be compacted daily for best performance and space usage. Here is my script that could be run in cron and will compact all databases: #!/bin/bash IP="10.0.0.121" DBS=`curl -sS -X GET http://$IP:5984/_all_dbs | sed -r "s/([,\"[])|(\])+/ /g"` for d in $DBS; do curl -H "Content-Type: application/json" -X POST http://$IP:5984/$d/_compact done More informations about compacting could be found here external link (also for version 1.2.x).