GuidesOperate

Manage mutations

Inspect table mutations and cancel work that is still active.

Manage mutations

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

Before you begin

  • Use the analytics database. Create it with the database API if it does not exist.
  • Use an events table with enough rows for projection materialization to remain active.

1. Add a projection

A materialized projection creates a mutation for existing parts.

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

2. Materialize the projection

Start the projection materialization.

ALTER TABLE events MATERIALIZE PROJECTION by_tenant

3. Inspect mutations

Read the mutation ID and status from system.mutations.

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

4. Cancel active mutations

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

KILL MUTATION WHERE table = 'events'

Check the result

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

Next steps