CubDB.set_auto_compact
set_auto_compact
, go back to CubDB module for more information.
Specs
set_auto_compact( GenServer.server(), boolean() | {integer(), integer() | float()} ) :: :ok | {:error, String.t()}
Configures whether to perform automatic compaction, and how.
If set to false
, no automatic compaction is performed. If set to true
,
auto-compaction is performed, following a write operation, if at least 100
write operations occurred since the last compaction, and the dirt factor is at
least 0.25. These values can be customized by setting the auto_compact
option to {min_writes, min_dirt_factor}
.
It returns :ok
, or {:error, reason}
if setting
is invalid.
Compaction is performed in the background and does not block other operations, but can create disk contention, so it should not be performed unnecessarily often. When writing a lot into the database, such as when importing data from an external source, it is adviseable to turn off auto compaction, and manually run compaction at the end of the import.