On a secure cluster you must be an admin user to access this area of the DB Console. See DB Console security.
New in v22.2: The Insights page exposes problems that CockroachDB has detected in your workloads and schemas. The page also offers recommendations to improve the performance of your workloads. These are called insights in the DB Console.
The Insights page helps you:
- Identify SQL statements with high retry counts, slow execution, or suboptimal plans.
- Identify indexes that should be created, altered, replaced, or dropped to improve performance.
Workload Insights tab
The Workload Insights tab displays insights related to transaction and statement executions.
Transaction Executions view
To display this view, click Insights in the left-hand navigation of the DB Console and select Workload Insights > Transaction Executions. The Transaction Executions view provides an overview of all transaction executions that have been flagged with insights.
The rows in this page are populated from the crdb_internal.transaction_contention_events table.
- The results displayed in the Transaction Executions view will be available as long as the corresponding row in the
crdb_internal.transaction_contention_eventstable exists. Rows will exist as long assql.contention.event_store.capacityis not reached in each node. - The default tracing behavior captures a small percent of transactions so not all contention events will be recorded. When investigating transaction contention, you can set the
sql.trace.txn.enable_thresholdcluster setting to always capture contention events.
Transaction executions with the High Contention insight are transactions that experienced contention.
The following screenshot shows the execution of a transaction flagged with High Contention:
To view details of the execution, click an execution ID in the Latest Transaction Execution ID column.
- Latest Transaction Execution ID: The execution ID of the latest execution with the transaction fingerprint.
- Transaction Fingerprint ID: The transaction fingerprint ID of the latest transaction execution.
- Transaction Execution: The transaction fingerprint of the latest transaction execution.
- Insights: The insight for the transaction execution.
- High Contention: The transaction execution experienced high contention time according to the threshold set in the
sql.insights.latency_thresholdcluster setting.
- High Contention: The transaction execution experienced high contention time according to the threshold set in the
- Start Time (UTC): The timestamp when the transaction execution started.
- Contention Time: The amount of time the transaction execution spent waiting in contention.
- Application Name: The name specified by the
application_namesession setting.
Transaction execution details
The transaction execution details view provides more details on a transaction execution insight.
The following screenshot shows the execution details of the transaction execution in the preceding section:
The Insights column shows the name of the insight, in this case High Contention; the Details column provides details on the insight.
- Start Time (UTC): The time the transaction execution started.
- Transaction Fingerprint ID: The transaction fingerprint ID of the transaction execution.
Transaction with ID {transaction ID} waited on
This section provides details of the transaction executions that block the transaction ID flagged with High Contention:
- Transaction Execution ID: The execution ID of the blocking transaction execution.
- Transaction Fingerprint ID: The transaction fingerprint ID of the blocking transaction execution.
- Transaction Execution: The queries attempted in the transaction.
- Contention Start Time (UTC): The timestamp at which contention was detected for the transaction.
- Contention Time: The time transactions with this execution ID was in contention with other transactions within the specified time interval.
- Schema Name: The name of the contended schema.
- Database Name: The name of the contended database.
- Table Name: The name of the contended table.
- Index Name: The name of the contended index.
Statement Executions view
The Statement Executions view provides an overview of all statement executions that have been flagged with insights.
To display this view, click Insights in the left-hand navigation of the DB Console and select Workload Insights > Statement Executions.
crdb_internal.cluster_execution_insights table.- The results displayed on the Statement Executions view will be available as long as the number of rows in each node is less than the
sql.insights.execution_insights_capacitycluster setting. - The default tracing behavior enables captures a small percent of transactions so not all contention events will be recorded. When investigating query latency, you can set the
sql.trace.txn.enable_thresholdcluster setting to always capture contention events.
To view
The Insights column shows the name of the insight, in this case Suboptimal Plan; the Details column provides details on the insight; and the final column contains a Create Index button. Click the Create Index button to perform a query to mitigate the cause of the insight, in this case to create an index on the ride
CockroachDB uses the threshold of 6 executions before offering an insight because it assumes that you are no longer merely experimenting with a query at that point.