# Run a Standalone Compactor

> Learn how to run compaction as a separate process from your database clients

By default, SlateDB starts a background compactor inside each `Db` instance.
If you want to run compaction as a separate service (for example, on dedicated compute), you can:

1. Open the `Db` with compaction disabled.
2. Start a standalone compactor in a separate process.

Both processes must use the same `ObjectStore` and database path (the path is the prefix inside your object store).

## Create a Db with no compactor

To prevent `Db` from starting the embedded compactor, set `Settings::compactor_options` to `None` and use `Db::builder`:

<!-- could not inline /home/runner/work/slatedb/examples/src/db_without_compactor.rs -->

## Run a compactor without a Db

You can run the standalone compactor using the SlateDB CLI:

```bash
slatedb --env-file .env --path <db-path> run-compactor
```

The compactor runs until interrupted (Ctrl-C), then shuts down gracefully.

Alternatively, you can embed the compactor in your own process using `CompactorBuilder` and call `run`:

<!-- could not inline /home/runner/work/slatedb/examples/src/standalone_compactor.rs -->

:::note

The standalone compactor expects the database to already exist (a manifest must be present).
If you're creating a new database, open it once (like in the previous section) before starting the compactor.

:::
