> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# PAUSE JOB

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `PAUSE JOB` <InternalLink path="sql-statements">statement</InternalLink> lets you pause the following types of jobs:

* <InternalLink path="import-into">`IMPORT`</InternalLink> jobs
* <InternalLink path="backup">`BACKUP`</InternalLink> and <InternalLink path="restore">`RESTORE`</InternalLink> jobs
* <InternalLink path="create-statistics">User-created table statistics</InternalLink> jobs
* <InternalLink path="cost-based-optimizer#table-statistics">Automatic table statistics</InternalLink> jobs
* <InternalLink path="create-changefeed">Changefeeds</InternalLink>
* <InternalLink path="online-schema-changes">Schema change</InternalLink> jobs
* <InternalLink path="manage-a-backup-schedule">Scheduled backup</InternalLink> jobs

After pausing jobs, you can resume them with <InternalLink path="resume-job">`RESUME JOB`</InternalLink>.

<Note>
  If a schema change job is paused, any jobs waiting on that schema change will stop waiting and return an error.
</Note>

## Required privileges

To pause a job, the user must be a member of the `admin` role or must have the <InternalLink path="create-user#create-a-user-that-can-pause-resume-and-cancel-non-admin-jobs">`CONTROLJOB`</InternalLink> <InternalLink path="security-reference/authorization">role option</InternalLink> set. Non-admin users cannot pause admin users' jobs.

For changefeeds, users with the <InternalLink path="create-changefeed#required-privileges">`CHANGEFEED`</InternalLink> privilege on a set of tables can pause changefeed jobs running on those tables.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/gtjMfbHiKZTUwAsm/images/sql-diagrams/v25.2/pause_job.svg?fit=max&auto=format&n=gtjMfbHiKZTUwAsm&q=85&s=8e0bc0e75e83d1889c5c144d2af5819c" alt="pause_job syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="745" height="299" data-path="images/sql-diagrams/v25.2/pause_job.svg" />

### Pause all jobs by type

<img src="https://mintcdn.com/cockroachlabs/gtjMfbHiKZTUwAsm/images/sql-diagrams/v25.2/pause_all_jobs.svg?fit=max&auto=format&n=gtjMfbHiKZTUwAsm&q=85&s=23c94a59fdc183aacd054bcdf06e3752" alt="pause_all_jobs syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="433" height="169" data-path="images/sql-diagrams/v25.2/pause_all_jobs.svg" />

<img src="https://mintcdn.com/cockroachlabs/AuLA5JIPpNnT7nbC/images/generated/docs/v25.2/pause-job/syntax-diagram-03605f8ad337.svg?fit=max&auto=format&n=AuLA5JIPpNnT7nbC&q=85&s=018e175663b2c26fdea5783f2db60e26" alt="SQL syntax diagram" width="433" height="169" data-path="images/generated/docs/v25.2/pause-job/syntax-diagram-03605f8ad337.svg" />

## Parameters

| Parameter                                   | Description                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `job\_id`                                   | The ID of the job you want to pause, which can be found with <InternalLink path="show-jobs">`SHOW JOBS`</InternalLink>.                                                                                                                                                                                                |
| `select\_stmt`                              | A <InternalLink path="selection-queries">selection query</InternalLink> that returns `job\_id`(s) to pause.                                                                                                                                                                                                            |
| `for\_schedules\_clause`                    | The schedule you want to pause jobs for. You can pause jobs for a specific schedule (`FOR SCHEDULE id`) or pause jobs for multiple schedules by nesting a <InternalLink path="select-clause">`SELECT` clause</InternalLink> in the statement (`FOR SCHEDULES `). See the [examples](#pause-jobs-for-a-schedule) below. |
| `WITH REASON = ...`                         | The reason to pause the job. CockroachDB stores the reason in the job's metadata, but there is no way to display it.                                                                                                                                                                                                   |
| `BACKUP`, `CHANGEFEED`, `RESTORE`, `IMPORT` | The job type to pause.                                                                                                                                                                                                                                                                                                 |

## Monitoring paused jobs

We recommend monitoring paused jobs. Jobs that are paused for a long period of time can start to affect the cluster in the following ways:

* A paused <InternalLink path="backup">backup</InternalLink>, <InternalLink path="restore">restore</InternalLink>, or index backfill job ( <InternalLink path="online-schema-changes">schema change</InternalLink> ) will continue to hold a <InternalLink path="architecture/storage-layer#protected-timestamps">protected timestamp</InternalLink> record on the data the job is operating on. This could result in data accumulation as the older versions of the keys cannot be <InternalLink path="architecture/storage-layer#garbage-collection">garbage collected</InternalLink>. In turn, this may cause increased disk usage and degraded performance for some workloads. See <InternalLink path="create-schedule-for-backup#protected-timestamps-and-scheduled-backups">Protected timestamps and scheduled backups</InternalLink> for more detail.
* A paused <InternalLink path="create-changefeed">changefeed</InternalLink> job, if <InternalLink path="create-changefeed">`protect_data_from_gc_on_pause`</InternalLink> is set, will also hold a protected timestamp record on the data the job is operating on. Depending on the value of <InternalLink path="create-changefeed">`gc_protect_expires_after`</InternalLink>, this can lead to data accumulation. Once `gc_protect_expires_after` elapses, the protected timestamp record will be released and the changefeed job will be canceled. See <InternalLink path="protect-changefeed-data">Garbage collection and changefeeds</InternalLink> for more detail.

To avoid these issues, use the `jobs.{job_type}.currently_paused` metric to track the number of jobs (for each job type) that are currently considered paused.

You can monitor protected timestamps relating to particular CockroachDB jobs with the following metrics:

* `jobs.{job_type}.protected_age_sec` tracks the oldest protected timestamp record protecting <code>{'{job_type}'}</code> jobs. As this metric increases, garbage accumulation increases. Garbage collection will not progress on a table, database, or cluster if the protected timestamp record is present.
* `jobs.{job_type}.protected_record_count` tracks the number of protected timestamp records held by <code>{'{job_type}'}</code> jobs.

For a full list of the available job types, access your cluster's <InternalLink path="monitoring-and-alerting#prometheus-endpoint">`/_status/vars`</InternalLink> endpoint.

See the following pages for details on metrics:

* <InternalLink path="monitor-and-debug-changefeeds">Monitor and Debug Changefeeds</InternalLink>
* <InternalLink path="backup-and-restore-monitoring">Backup and Restore Monitoring</InternalLink>
* <InternalLink path="metrics">Metrics</InternalLink>

## Examples

### Pause a single job

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW JOBS;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
      job_id     |  job_type |               description                      |...
-----------------+-----------+------------------------------------------------+...
  27536791415282 |  RESTORE  | RESTORE db.* FROM 'azure-blob://backup/db/tbl' |...
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> PAUSE JOB 27536791415282;
```

### Pause multiple jobs

To pause multiple jobs, nest a <InternalLink path="select-clause">`SELECT` clause</InternalLink> that retrieves `job_id`(s) inside the `PAUSE JOBS` statement:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> PAUSE JOBS (WITH x AS (SHOW JOBS) SELECT job_id FROM x
      WHERE user_name = 'maxroach');
```

All jobs created by `maxroach` will be paused.

### Pause by job type

To pause all jobs by the type of job, use the `PAUSE ALL {job} JOBS` statement. You can pause all `BACKUP`, `RESTORE`, `CHANGEFEED`, `IMPORT` jobs using this statement, for example:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
PAUSE ALL BACKUP JOBS;
```

### Pause automatic table statistics jobs

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW AUTOMATIC JOBS;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
        job_id       |       job_type      |                    description                      |...
---------------------+---------------------+-----------------------------------------------------+...
  438235476849557505 |  AUTO CREATE STATS  | Table statistics refresh for defaultdb.public.users |...
(1 row)
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> PAUSE JOB 438235476849557505;
```

To permanently disable automatic table statistics jobs, disable the `sql.stats.automatic_collection.enabled` <InternalLink path="cluster-settings">cluster setting</InternalLink>:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
```

### Pause jobs for a schedule

To pause jobs for a specific <InternalLink path="create-schedule-for-backup">backup schedule</InternalLink>, use the schedule's `id`:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> PAUSE JOBS FOR SCHEDULE 590204387299262465;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
PAUSE JOBS FOR SCHEDULES 1
```

You can also pause multiple schedules by nesting a <InternalLink path="select-clause">`SELECT` clause</InternalLink> that retrieves `id`(s) inside the `PAUSE JOBS` statement:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> PAUSE JOBS FOR SCHEDULES WITH x AS (SHOW SCHEDULES) SELECT id FROM x WHERE label = 'test_schedule';
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
PAUSE JOBS FOR SCHEDULES 2
```

## See also

* <InternalLink path="resume-job">`RESUME JOB`</InternalLink>
* <InternalLink path="show-jobs">`SHOW JOBS`</InternalLink>
* <InternalLink path="cancel-job">`CANCEL JOB`</InternalLink>
* <InternalLink path="backup">`BACKUP`</InternalLink>
* <InternalLink path="restore">`RESTORE`</InternalLink>
* <InternalLink path="import-into">`IMPORT INTO`</InternalLink>
* <InternalLink path="create-changefeed">`CREATE CHANGEFEED`</InternalLink>
