# Manage mutations (/docs/guides/operate/mutations)



Manage mutations [#manage-mutations]

Mutations change existing table parts. They run asynchronously and use server
resources while they process data.

Before you begin [#before-you-begin]

* Use the `analytics` database. Create it with the [database API](/docs/reference/api/databases#post-v1databases) if it does not exist.
* Use an `events` table with enough rows for projection materialization to remain active.

1\. Add a projection [#1-add-a-projection]

A materialized projection creates a mutation for existing parts.

```sql test
ALTER TABLE events ADD PROJECTION by_tenant (SELECT `__raw_data.tenant`, count() GROUP BY `__raw_data.tenant`)
```

2\. Materialize the projection [#2-materialize-the-projection]

Start the projection materialization.

```sql test
ALTER TABLE events MATERIALIZE PROJECTION by_tenant
```

3\. Inspect mutations [#3-inspect-mutations]

Read the mutation ID and status from `system.mutations`.

```sql test
SELECT mutation_id, command, is_done, is_killed FROM system.mutations WHERE database = currentDatabase() AND table = 'events'
```

4\. Cancel active mutations [#4-cancel-active-mutations]

Cancel unfinished mutations for `events`. Add the `mutation_id` condition to
target one mutation.

```sql test
KILL MUTATION WHERE table = 'events'
```

Check the result [#check-the-result]

Inspect `system.mutations` after the request. The row shows whether the mutation
is complete or marked as killed.

Next steps [#next-steps]

* [Mutation concepts](/docs/concepts/mutations)
* [KILL MUTATION statements](/docs/reference/sql/statements/kill-mutation)
