4.7. Compaction Configuration
4.7.1. Database Compaction Options
[database_compaction]
4.7.2. Compaction Daemon Rules
[compactions]
A list of rules to determine when to run automatic compaction. Thedaemons/compaction_daemon
compacts databases and their respectiveview groups when all the condition parameters are satisfied. Configurationcan be per-database or global, and it has the following format:- [compactions]
databasename = [ {ParamName, ParamValue}, {ParamName, ParamValue}, … ]
_default = [ {ParamName, ParamValue}, {ParamName, ParamValue}, … ]
For example:- [compactions]
_default = [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "23:00"}, {to, "04:00"}]
-db_fragmentation
: If the ratio of legacy data, including metadata, tocurrent data in the database file size is equal to or greater than thisvalue, this condition is satisfied. The percentage is expressed as aninteger percentage. This value is computed as:- (file_size - data_size) / file_size 100
The data_size and file_size values can be obtained whenqueryingGET /{db}
.
-view_fragmentation
: If the ratio of legacy data, including metadata,to current data in a view index file size is equal to or greater thenthis value, this database compaction condition is satisfied. Thepercentage is expressed as an integer percentage. This value is computedas:- (file_size - data_size) / file_size 100
The data_size and file_size values can be obtained when querying aview group’s information URI.
-from
andto
: The period for which a database (and its view group)compaction is allowed. The value for these parameters must obey theformat:- HH:MM - HH:MM (HH in [0..23], MM in [0..59])
-strict_window
: If a compaction is still running after the end of theallowed period, it will be canceled if this parameter is set to _true.It defaults to false and is meaningful only if the period parameteris also specified.
-parallelview_compaction
: If set to _true, the database and itsviews are compacted in parallel. This is only useful on certain setups,like for example when the database and view index directories point todifferent disks. It defaults to false.
Before a compaction is triggered, an estimation of how much free disk spaceis needed is computed. This estimation corresponds to two times the datasize of the database or view index. When there’s not enough free disk spaceto compact a particular database or view index, a warning message islogged.
Examples:
-- [{dbfragmentation, "70%"}, {view_fragmentation, "60%"}]
The _foo database is compacted if its fragmentation is 70% or more. Anyview index of this database is compacted only if its fragmentation is60% or more.
-- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}]
Similar to the preceding example but a compaction (database or viewindex) is only triggered if the current time is between midnight and 4AM.
-- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}, {strict_window, true}]
Similar to the preceding example - a compaction (database or view index)is only triggered if the current time is between midnight and 4 AM. Ifat 4 AM the database or one of its views is still compacting, thecompaction process will be canceled.
-- [{db_fragmentation, "70%"}, {view_fragmentation, "60%"}, {from, "00:00"}, {to, "04:00"}, {strict_window, true}, {parallel_view_compaction, true}]
Similar to the preceding example, but a database and its views can becompacted in parallel.- [compactions]
4.7.3. Configuration of Compaction Daemon
[compaction_daemon]
4.7.4. Views Compaction Options
原文: http://docs.couchdb.org/en/stable/config/compaction.html