Skip to main content
The SQL metrics let you monitor . To view these graphs, select a cluster from the , and click Metrics in the Monitoring section of the left side navigation. On the Metrics page, click the SQL tab.

Time interval selection

The time interval selector at the top of each tab allows you to filter the view for a predefined or custom time interval. Use the navigation buttons to move to the previous, next, or current time interval. When you select a time interval, the same interval is selected for all charts on the Metrics page.

SQL Connections

Short NameCockroachDB Metric NameDescriptionUsage
Connections Per Secondsql.new\_connsNumber of SQL connections createdThe rate of this metric shows how frequently new connections are being established. This can be useful in determining if a high rate of incoming new connections is causing additional load on the server due to a misconfigured application.

SQL Statements

Short NameCockroachDB Metric NameDescriptionUsage
Selectsql.select.countNumber of SQL SELECT statements successfully executedThis high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric’s time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
Updatesql.update.countNumber of SQL UPDATE statements successfully executedThis high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric’s time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
Insertsql.insert.countNumber of SQL INSERT statements successfully executedThis high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric’s time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
Deletesql.delete.countNumber of SQL DELETE statements successfully executedThis high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric’s time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.

Service Latency: SQL Statements

Short NameCockroachDB Metric NameDescriptionUsage
P90, P99, P99.9, P99.99sql.service.latencyLatency of SQL request executionThese high-level metrics reflect workload performance. Monitor these metrics to understand latency over time. If abnormal patterns emerge, apply the metric’s time range to the SQL Activity pages to investigate interesting outliers or patterns. The Statements page has P90 Latency and P99 latency columns to enable correlation with this metric.

Connection Latency

Short NameCockroachDB Metric NameDescriptionUsage
P90, P99sql.conn.latencyLatency to establish and authenticate a SQL connectionThese metrics characterize the database connection latency which can affect the application performance, for example, by having slow startup times. Connection failures are not recorded in these metrics.

Open SQL Sessions

Short NameCockroachDB Metric NameDescriptionUsage
Connectionssql.connsNumber of open SQL connectionsThis metric shows the number of connections as well as the distribution, or balancing, of connections across cluster nodes. An imbalance can lead to nodes becoming overloaded. Review Connection Pooling.

Open SQL Transactions

Short NameCockroachDB Metric NameDescriptionUsage
Open Transactionssql.txns.openNumber of currently open user SQL transactionsThis metric should roughly correspond to the number of cores * 4. If this metric is consistently larger, scale out the cluster.

Transactions

Short NameCockroachDB Metric NameDescriptionUsage
Beginsql.txn.begin.countNumber of SQL transaction BEGIN statements successfully executedThis metric reflects workload volume by counting explicit transactions. Use this metric to determine whether explicit transactions can be refactored as implicit transactions (individual statements).
Commitssql.txn.commit.countNumber of SQL transaction COMMIT statements successfully executedThis metric shows the number of transactions that completed successfully. This metric can be used as a proxy to measure the number of successful explicit transactions.
Rollbackssql.txn.rollback.countNumber of SQL transaction ROLLBACK statements successfully executedThis metric shows the number of orderly transaction rollbacks. A persistently high number of rollbacks may negatively impact the workload performance and needs to be investigated.
Abortssql.txn.abort.countNumber of SQL transaction abort errorsThis high-level metric reflects workload performance. A persistently high number of SQL transaction abort errors may negatively impact the workload performance and needs to be investigated.

Transaction Restarts

Short NameCockroachDB Metric NameDescriptionUsage
Write Too Oldtxn.restarts.writetoooldNumber of restarts due to a concurrent writer committing firstThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated.
Write Too Old (multiple)txn.restarts.writetoooldmultiThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated. For the specific error, refer to the transaction retry error reference for more details.
Forwarded Timestamptxn.restarts.serializableNumber of restarts due to a forwarded commit timestamp and isolation=SERIALIZABLEThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated.
Async Consensus Failuretxn.restarts.asyncwritefailureNumber of restarts due to async consensus writes that failed to leave intentsThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated. For the specific error, refer to the transaction retry error reference for more details.
Read Within Uncertainty Intervaltxn.restarts.readwithinuncertaintyNumber of restarts due to reading a new value within the uncertainty intervalThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated. For the specific error, refer to the transaction retry error reference for more details.
Abortedtxn.restarts.txnabortedNumber of restarts due to an abort by a concurrent transaction (usually due to deadlock)The errors tracked by this metric are generally due to deadlocks. Deadlocks can often be prevented with a considered transaction design. Identify the conflicting transactions involved in the deadlocks, then, if possible, redesign the business logic implementation prone to deadlocks.
Push Failuretxn.restarts.txnpushNumber of restarts due to a transaction push failureThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated.
Unknowntxn.restarts.unknownNumber of restarts due to a unknown reasonsThis metric is one measure of the impact of contention conflicts on workload performance. For guidance on contention conflicts, review transaction contention best practices and performance tuning recipes. Tens of restarts per minute may be a high value, a signal of an elevated degree of contention in the workload, which should be investigated.

Transaction Latency

Short NameCockroachDB Metric NameDescriptionUsage
P90, P99sql.txn.latencyLatency of SQL transactionsThese high-level metrics provide a latency histogram of all executed SQL transactions. These metrics provide an overview of the current SQL workload.

Active SQL Statements

Short NameCockroachDB Metric NameDescriptionUsage
Active Statementssql.statements.activeNumber of currently active user SQL statementsThis high-level metric reflects workload volume.

SQL Statement Errors

Short NameCockroachDB Metric NameDescriptionUsage
Errorssql.failure.countNumber of statements resulting in a planning or runtime errorThis metric is a high-level indicator of workload and application degradation with query failures. Use the Insights page to find failed executions with their error code to troubleshoot or use application-level logs, if instrumented, to determine the cause of error.

SQL Statement Contention

Short NameCockroachDB Metric NameDescriptionUsage
Contentionsql.distsql.contended\_queries.countNumber of SQL queries that experienced contentionThis metric is incremented whenever there is a non-trivial amount of contention experienced by a statement whether read-write or write-write conflicts. Monitor this metric to correlate possible workload performance issues to contention conflicts.

Full Scans

Short NameCockroachDB Metric NameDescriptionUsage
Full scanssql.full.scan.countNumber of full table or index scansThis metric is a high-level indicator of potentially suboptimal query plans in the workload that may require index tuning and maintenance. To identify the statements with a full table scan, use SHOW FULL TABLE SCAN or the SQL Activity Statements page with the corresponding metric time frame. The Statements page also includes explain plans and index recommendations. Not all full scans are necessarily bad especially over smaller tables.

Schema Changes

Short NameCockroachDB Metric NameDescriptionUsage
DDL Statementssql.ddl.countNumber of SQL DDL statements successfully executedThis high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric’s time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.

Statistics Jobs

Short NameCockroachDB Metric NameDescriptionUsage
Auto Create Statistics Runningjobs.auto\_create\_stats.currently\_runningNumber of auto_create_stats jobs currently running in Resume or OnFailOrCancel stateThis metric tracks the number of active automatically generated statistics jobs that could also be consuming resources. Ensure that foreground SQL traffic is not impacted by correlating this metric with SQL latency and query volume metrics.
Create Statistics Runningjobs.create\_stats.currently\_runningNumber of create_stats jobs currently running in Resume or OnFailOrCancel stateThis metric tracks the number of active create statistics jobs that could also be consuming resources. Ensure that foreground SQL traffic is not impacted by correlating this metric with SQL latency and query volume metrics.
Auto Create Statistics Failedjobs.auto\_create\_stats.resume\_failedNumber of auto_create_stats jobs which failed with a non-retriable errorThis metric is a high-level indicator that automatically generated table statistics is failing. Failed statistic creation can lead to the query optimizer running with stale statistics. Stale statistics can cause suboptimal query plans to be selected leading to poor query performance.
Auto Create Statistics Pausedjobs.auto\_create\_stats.currently\_pausedNumber of auto_create_stats jobs currently considered PausedThis metric is a high-level indicator that automatically generated statistics jobs are paused which can lead to the query optimizer running with stale statistics. Stale statistics can cause suboptimal query plans to be selected leading to poor query performance.

See also