SHOW JOBS statement lists all of the types of long-running tasks your cluster has performed in the last 12 hours, including:
-
Schema changes through
ALTER TABLE,DROP DATABASE,DROP TABLE, andTRUNCATE -
IMPORT. -
Enterprise
BACKUPandRESTORE. - Scheduled backups.
-
User-created table statistics created for use by the cost-based optimizer. To view automatic table statistics, use
SHOW AUTOMATIC JOBS. -
SHOW JOBSnow displays newly added columns fromcrdb_internal.jobs(last_run,next_run,num_runs, andexecution_errors). The columns capture state related to retries, failures, and exponential backoff. These details can help you understand the status of crucial tasks that can impact the performance of your cluster, as well as help you control them.
SHOW JOBS statement. For details about enterprise changefeeds, including the sink URI and the full table name, use SHOW CHANGEFEED JOBS.
To block a call to SHOW JOBS that returns after all specified job ID(s) have a terminal state, use SHOW JOBS WHEN COMPLETE. The statement will return a row per job ID, which provides details of the job execution. Note that while this statement is blocking, it will time out after 24 hours.
Considerations
- The
SHOW JOBSstatement shows only long-running tasks. - For jobs older than 12 hours, query the
crdb_internal.jobstable. - For the
SHOW JOBSstatement, jobs are deleted after 14 days. This interval can be changed via thejobs.retention_timecluster setting. See Show changefeed jobs for changefeed job retention time. - While the
SHOW JOBS WHEN COMPLETEstatement is blocking, it will time out after 24 hours. - Garbage collection jobs are created for dropped tables and dropped indexes, and will execute after the GC TTL has elapsed. These jobs cannot be canceled.
- CockroachDB automatically retries jobs that fail due to retry errors or job coordination failures, with exponential backoff. The
jobs.registry.retry.initial_delaycluster setting sets the initial delay between retries andjobs.registry.retry.max_delaysets the maximum delay.
Required privileges
You must have at least one of the following to runSHOW JOBS:
- New in v23.1: The
VIEWJOBprivilege, which can view all jobs (includingadmin-owned jobs). - Be a member of the
adminrole. - The
CONTROLJOBrole option. - For changefeeds, users with the
CHANGEFEEDprivilege on a set of tables can view changefeed jobs running on those tables.
Synopsis
Parameters
Response
The output ofSHOW JOBS lists ongoing jobs first, then completed jobs within the last 12 hours. The list of ongoing jobs is sorted by starting time, whereas the list of completed jobs is sorted by finished time.
The following fields are returned for each job:
For details of changefeed-specific responses, see
SHOW CHANGEFEED JOBS.
Job status
We recommend monitoring paused jobs to protect historical data from garbage collection, or potential data accumulation in the case of changefeeds. See Monitoring paused jobs for detail on metrics to track paused jobs and protected timestamps.
Examples
Show jobs
Filter jobs
You can filter jobs by usingSHOW JOBS as the data source for a SELECT statement, and then filtering the values with the WHERE clause.
Show automatic jobs
AUTO SPAN CONFIG RECONCILIATION: A continuously running job that ensures that all declared zone configurations (ALTER … CONFIGURE ZONE …) are applied. For example, whennum_replicas = 7is set on a table, the reconciliation job listens in on those changes and then informs the underlying storage layer to maintain 7 replicas for the table.AUTO SQL STATS COMPACTION: An hourly job that truncates the internalsystem.statement_statisticsandsystem.transaction_statisticstable row counts to the value of thesql.stats.persisted_rows.maxcluster setting. Both tables contribute to thecrdb_internal.statement_statisticsandcrdb_internal.transaction_statisticstables, respectively.AUTO CREATE STATS: Creates and updates table statistics.
Filter automatic jobs
You can filter jobs by usingSHOW AUTOMATIC JOBS as the data source for a SELECT statement, and then filtering the values with the WHERE clause.
Show changefeed jobs
You can display specific fields relating to changefeed jobs by runningSHOW CHANGEFEED JOBS. These fields include:
high_water_timestamp: Guarantees all changes before or at this time have been emitted.sink_uri: The destination URI of the configured sink for a changefeed.full_table_names: The full name resolution for a table. For example,defaultdb.public.mytablerefers to thedefaultdbdatabase, thepublicschema, and the tablemytabletable.
topics: The topic name to which Kafka and Google Cloud Pub/Sub changefeed messages will emit. If you start a changefeed with thesplit_column_familiesoption targeting a table with multiple column families, theSHOW CHANGEFEED JOBSoutput will show the topic name with a family placeholder. For example,topic.{family}.format: The format of the changefeed messages, e.g.,json,avro.
jobs.retention_time cluster setting.
Filter changefeed jobs
You can filter jobs by usingSHOW CHANGEFEED JOBS as the data source for a SELECT statement, and then filtering the values with a WHERE clause. For example, you can filter by the status of changefeed jobs:
Show schema changes
You can show just schema change jobs by usingSHOW JOBS as the data source for a SELECT statement, and then filtering the job_type value with the WHERE clause:
Show job when complete
To blockSHOW JOB until the provided job ID reaches a terminal state, use SHOW JOB WHEN COMPLETE:
Show jobs for a schedule
To view jobs for a specific backup schedule, use the schedule’sid:
SELECT clause that retrieves id(s) inside the SHOW JOBS statement:

