<a id="flink-sql-move-statement-compute-pool"></a>

# Move a Statement to a Different Compute Pool

If a [compute pool](../concepts/compute-pools.md#flink-sql-compute-pools) is close to its Confluent
Flink Unit (CFU) limit, you can move a running statement to a different pool
that has available capacity, instead of increasing the pool’s `MAX_CFU`.

This procedure applies only to a *background statement*, one that writes
results to a table or topic, like an `INSERT INTO` statement or a
materialized table’s underlying statement. A *foreground statement*, like an
ad-hoc `SELECT` you run in a workspace cell, writes its results directly to
the UI or a client, and stopping it doesn’t take a
[savepoint](../operate-and-deploy/carry-over-offsets.md#flink-sql-carry-over-offsets-statement-type-limitations).
Without a savepoint, there’s no state to resume from, so a foreground
statement can’t be moved to a different compute pool. For more information
about statement types, see [Flink SQL Statements in Confluent Cloud for Apache Flink](../concepts/statements.md#flink-sql-statements).

Moving a statement requires three steps, regardless of which interface you
use:

1. Stop the statement.
2. Change its compute pool.
3. Resume the statement.

## Prerequisites

- Access to Confluent Cloud.
- An existing background statement.
- Another compute pool with available CFU capacity, in the same environment
  and region as the statement.

## Move a statement using the Console

1. Log in to Confluent Cloud Console and navigate to the environment that has your
   statement.
2. In the navigation menu, click **Flink management**, then click
   **Statements**, if it’s not selected already.
3. Click the name of the statement you want to move.

   The statement’s details page opens.
4. Click **Stop**, and in the confirmation dialog, click **Confirm**.

   Confluent Cloud takes a savepoint and stops the statement.
5. Click the **Settings** tab.
6. Click **Edit Settings**.

   The **Edit settings** panel opens, showing the statement’s current
   compute pool and account.
7. In the **Compute pool** dropdown, select a different compute pool.
8. Click **Save and Resume**.

   Confluent Cloud resumes the statement under the new compute pool, continuing
   from the savepoint.

## Move a statement using the Confluent CLI

Run the
[confluent flink statement update](../reference/flink-sql-cli.md#flink-sql-confluent-cli-update-statement) command to stop the statement,
then run it again to resume the statement under a different compute pool.

```bash
# Stop the statement.
confluent flink statement update ${STATEMENT_NAME} --stopped=true

# Resume the statement under a different compute pool.
confluent flink statement update ${STATEMENT_NAME} --stopped=false --compute-pool ${COMPUTE_POOL_ID}
```

## Move a statement using the REST API

Send a [PUT request](../operate-and-deploy/flink-rest-api.md#flink-rest-api-update-statement) to the Statements
endpoint with `stopped` set to `true` to stop the statement. After the
statement stops, send another PUT request with `stopped` set to `false`
and `compute_pool_id` set to the new pool’s ID to resume the statement.
For a complete example, see
[Move a statement to a different compute pool](../operate-and-deploy/flink-rest-api.md#flink-rest-api-move-statement-compute-pool).

## Move a statement using Terraform

In the `confluent_flink_statement` resource, set the `stopped` attribute
to `true` and run `terraform apply` to stop the statement. After it stops,
change the `compute_pool` block’s `id` attribute to the new pool and change
`stopped` back to `false`, then run `terraform apply` again. You must
change the compute pool and transition the statement from stopped to running in
the same apply. For more information, see
[Statements](../operate-and-deploy/terraform.md#flink-sql-terraform-statements).

## Related content

- [Flink SQL Statements in Confluent Cloud for Apache Flink](../concepts/statements.md#flink-sql-statements)
- [Compute Pools in Confluent Cloud for Apache Flink](../concepts/compute-pools.md#flink-sql-compute-pools)
- [Manage Compute Pools in Confluent Cloud for Apache Flink](../operate-and-deploy/create-compute-pool.md#flink-sql-manage-compute-pool)
- [Carry-over Offsets in Confluent Cloud for Apache Flink](../operate-and-deploy/carry-over-offsets.md#flink-sql-carry-over-offsets)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
