Method | POST /db/_compact | |
Request | None | |
Response | JSON success statement | |
Admin Privileges Required | no | |
Return Codes | ||
202 | Compaction request has been accepted | |
404 | The requested content could not be found. The returned content will include further information, as a JSON object, if available. |
Request compaction of the specified database. Compaction compresses the disk database file by performing the following operations:
Writes a new version of the database file, removing any unused sections from the new version during write. Because a new file is temporary created for this purpose, you will need twice the current storage space of the specified database in order for the compaction routine to complete.
Removes old revisions of documents from the database, up to
the per-database limit specified by the
_revs_limit
database parameter. See
Section 5.1, “GET /db
” .
Compaction can only be requested on an individual database; you cannot compact all the databases for a CouchDB instance. The compaction process runs as a background process.
You can determine if the compaction process is operating on a
database by obtaining the database meta information, the
compact_running
value of the returned database
structure will be set to true. See
Section 5.1, “GET /db
” .
You can also obtain a list of running processes to determine
whether compaction is currently running. See
Section 9.2, “GET /_active_tasks
”.