Auto-Compaction settings determine the compaction process; whereby databases and their respective view-indexes are compacted. These settings can only be established by Full and Cluster Administrators.
Auto-Compaction is enabled by default for all Couchbase buckets. However, settings can be overridden on a per bucket basis.
To access the Auto-Compaction settings:
- For a new bucket:
Access the Buckets screen provided by the Couchbase Web Console. Left-click on the Add Bucket button:
When the Add Data Bucket dialog appears, add appropriate data into the initial fields; then left-click on the Advanced bucket settings tab:
The dialog now expands, and displays additional configuration-options. Access the Auto-Compaction panel, and check the Override the default auto-compaction settings? checkbox:
The dialog expands again, and displays Auto-Compaction settings available for this bucket.
- For an existing bucket:
Left-click on the information-row for the bucket, on the Buckets screen of the Couchbase Web Console. When the Edit button appears, left-click on it:
This brings up the Edit Bucket Settings dialog: left-click on the Show advanced bucket settings tab. Access the Auto-Compaction panel, and check the Override the default auto-compaction settings? checkbox. The dialog expands, thereby showing the available Auto-Compaction settings.
- For all buckets for which no override is specified:
Left-click on the Settings tab, in the vertical navigation-bar at the left-hand side. When the Settings screen appears, left-click on the Auto-Compaction tab, on the horizontal control-bar at the top:
This brings up the Auto-Compaction screen.
The Auto-Compaction view of the Settings screen appears as follows. (Note that the Index Fragmentation settings are only displayed for Couchbase Server Community Edition.)
All settings on this screen are also provided on the dialogs whereby you establish custom-settings for an individual new or existing bucket — with the exception of the settings for Index Fragmentation, which can only be established on a cluster-wide basis.
Settings constitute conditions, which must be met for the compaction-process to be triggered. The settings are described below.
The Database Fragmentation panel appears as follows:
Compaction is triggered when database-fragmentation reaches the point specified by means of this interface. You can specify the fragmentation-level as a percentage (the upper field, selected by checking the adjacent checkbox); or as a number of megabytes (the lower).
The View Fragmentation panel appears as follows:
Compaction is triggered when view-fragmentation reaches the point specified by means of this interface. You can specify the fragmentation-level as a percentage (the upper field, selected by checking the adjacent checkbox); or as a number of megabytes (the lower).
The Time Interval pane provides a number of settings whereby compaction is scheduled:
To set a time-interval during which compaction is permitted to run, check the checkbox at the top of the pane. Then, add a start and an end time into the interactive fields. Note that each left-hand field specifies the hour-of-the-day; while each right-hand specifies the minute-of-the-hour.
Checkboxes are provided to allow you to specify: first, that compaction can be aborted if the specified time is exceeded; secondly, that database and view compaction are executed simultaneously (implying a heavier processing and disk I/O load, during the compaction-process).
For example, the following, completed Time Interval pane specifies that compaction should run between 1:00 am and 2:30 am; should be aborted if not completed in time; and should feature parallel compaction of database and indexes:
These settings are only available in Couchbase Server Community Edition.
The Index Fragmentation panel provides settings that cannot be overridden at individual bucket-level. The panel appears as follows:
This interface sets the write-strategy and trigger-point for compaction.
Select from the following options:
- Append-only write mode with index fragmentation level trigger
Turns on append only writes for index-storage, and triggers the compaction-job based on the fragmentation-level of each index file. Check the checkbox, then specify a fragmentation-level as a percentage, in the interactive text-field.
- Circular write mode with day + time interval trigger
Turns on writes with circular reuse, for index-storage, and triggers the compaction-job based on a time-interval. To specify when compaction is permitted to run, select appropriate days of the week, by checking the appropriate checkboxes; then, select the start-time on each of those days; and optionally, an end-time.
Optionally, check the Abort compaction if run time exceeds the set time interval checkbox: if you do so, compaction is aborted if the specified end-time is exceeded.
Note that whenever you change the compaction settings for the index, the system starts the global secondary index process on all the nodes.
Sets the frequency of the tombstone (metadata) purge interval. The default value is three days. The panel appears as follows:
Tombstones are records of expired or deleted items.
They include key and metadata.
Tombstones are used in Couchbase Server to provide eventual consistency of data between clusters.
The auto-compaction process waits for the specified number of days before permanently deleting tombstones for expired or deleted items.
The default value is three days.
The recommended range of values is
0.04 equals one hour, and
1 equals one day.
Note that if you set this value too low, you may see inconsistent results in views queries, such as deleted items in a result set. You may also see inconsistent items in clusters with XDCR set up between the clusters. If you set this value too high, it will delay the server from reclaiming disk space.
For more information, see Storage.
Note that Auto-Compaction settings can also be modified using the Couchbase rest-api:rest-autocompact-get.adoc.