Skip to main content
This feature is in and is only available to enrolled organizations. To enroll your organization, contact your Cockroach Labs account team. This feature is subject to change.
The example workflows on this page show how to use Cockroach Aegis reports and recommendations alongside your own measurements on a test cluster. In each workflow, you generate a workload, examine the evidence Aegis produces, decide whether a change is appropriate, and check the observations after the workload or configuration changes. This page describes two workflows: Both workflows retrieve Aegis’s analysis through MCP and apply any changes through a separate SQL connection. Aegis can also explain a workload’s behavior without recommending a change, as the contention workflow shows. For information about how Aegis produces reports and recommendations, see Cockroach Aegis Overview. For MCP setup, see Connect through MCP.

Before you begin

  • Use a dedicated, non-production cluster with no other workload. These examples write data and consume cluster resources. The reference contention run used a single-node, 4-vCPU Advanced cluster, which is sufficient for that example. A production configuration would add nodes for fault tolerance and load distribution.
  • Connect the cluster to Aegis and keep the connector running. For instructions, see How do I connect a cluster?.
  • Connect an MCP client and verify instance and report access. For instructions, see Connect through MCP. The instructions shown here rely heavily on your agent using MCP.
  • Install the cockroach binary and check cockroach version. Each example specifies its workload commands. For more information, see cockroach workload.
  • Use a separate SQL credential with permission to create the test database, read and write its tables, and create an index when an example requires it. Keep the Aegis connector role at its recommended read-only grants; the workload and any applied changes use this separate credential.
  • Set PGURL to this test cluster’s connection URL, initially using defaultdb. Omit the password and retain sslmode=verify-full and the correct sslrootcert path. Supply the workload credential through PGPASSWORD using your normal secure credential-loading process, so that the password stays out of command arguments and shell history. For more information, see Connection parameters.
  • For a CockroachDB Cloud cluster, use the ccloud CLI to obtain these values. ccloud cluster sql --connection-url {cluster_name} returns a connection URL that already includes sslmode=verify-full and the path to the downloaded CA certificate, and ccloud cluster user create creates the workload SQL user. For more information, see and .

Understand transaction contention

In this example, you will run a small TPC-C workload and use Aegis reports to investigate transaction contention. You will compare the reports with workload measurements, reduce concurrency, and check whether later observations cover the change. The goal is to understand the evidence Aegis provides, and to understand the workflow.Check cockroach workload run tpcc --help before proceeding. Allow time for data initialization, two 12-minute measurement periods, and Aegis check-ins. The workload commands include a 30-second ramp before each measurement period. A check-in can complete without rewriting its reports, so allow for more than one check-in per phase.

Step 1. Prepare the test dataset

Confirm the SQL target and inspect the existing databases:
Verify that the host in PGURL is the intended test cluster. Choose an unused database name, changing the following example if the name already exists, so that no existing database is overwritten:
Initialize the dataset once. Both phases use it, and their transactions will change its data. Wait for initialization to finish successfully before continuing.TPC-C includes payment and new-order transactions that update shared rows. With 10 warehouses, payments update a small set of warehouse totals, and district updates touch a small set of totals and order counters. Concurrent transactions can end up waiting on these rows even when overall CPU utilization is low.For the underlying concepts, read Understand hotspots, particularly row hotspots, and Understand and avoid transaction contention.

Step 2. Capture an idle baseline

After initialization finishes, select the intended Aegis instance over MCP with list_instances and confirm its identity with get_instance. Retrieve get_reports and list_recommendations for that instance.Save the report bodies, check_in_id, and as_of, as well as each report’s changed, created_at, and version_id fields. Read the observation times inside the reports. Your baseline should describe the idle cluster after initialization. If it still describes initialization or an earlier workload, retain that context and wait for observations of the idle cluster.To get a fresh report, wait for a scheduled check-in or request one with Check in in the Aegis web UI. Retrieving reports through MCP leaves the check-in schedule unchanged. Check progress with get_instance before retrieving the completed snapshot.

Step 3. Run the higher-concurrency phase

Record the start time and run TPC-C with 32 active workers:
The command disables TPC-C think time and caps workload operations at 100 per second. These operations are multi-statement transactions, so the rate differs from SQL statements per second, and the cap is an upper bound rather than a guaranteed throughput.
This is a contention exercise rather than a compliant TPC-C benchmark or a capacity-sizing test.
Watch the output, and stop the workload if it reports errors or the cluster shows unexpected resource pressure. Keep the load as specified; the goal is to see how Aegis gathers evidence, and getting a recommendation is optional. If your cluster can run this workload comfortably, you may not see a recommendation. Save the final totals and the end time after the command exits successfully.While the workload runs, allow several minutes of observations, then request a check-in or wait for a scheduled one. When it completes, retrieve and save the reports and recommendations through MCP, and confirm that the report bodies describe this application’s activity during the run.

Step 4. Interpret the contention evidence

Ask your agent to compare the reports with the baseline using a prompt like the following:
Replace {instance_id} with the Aegis instance ID and {start_time_utc} with the recorded UTC start time. Supply the saved baseline reports in the conversation.In the reference run, Aegis identified contention on warehouse and district rows, including warehouse payment totals and district order counters. Its cluster report showed CPU and disk headroom. The workload report identified serialization retries and explained why optimizer index suggestions were not promoted into recommendations: those suggestions targeted scan paths that were a small part of the cost in this synthetic workload.What follows are suggestions for interpreting the findings:
  • Contention on a small set of keys can occur at low overall CPU. Updates to a single hot row serialize on that row, so adding nodes or an index can address different bottlenecks.
  • Serialization retries are distinct from failed transactions. The reference workload may have reported zero terminal errors, while Aegis was likely to identify retry events. For more information, see Transaction retry errors.
  • An empty recommendation list can accompany a report with substantial analysis. Read the report for the explanation.
  • Verify the diagnosis with the cluster’s contention and statement-performance views, filtered by the phase’s application name and time window, following the instructions in Monitor and analyze transaction contention. Note that cached contention entries can persist after load stops, so pair them with a time window when reading current contention.

Step 5. Compare reduced concurrency

Wait for the first command to exit. Record the next start time, then repeat the run with 8 active workers:
Keep --workers 32, the warehouse count, and the connection-pool limit unchanged. --active-workers 8 limits how many workers execute at once while preserving the existing workers’ warehouse assignments. The pool closes idle connections, so the live connection count varies under lower load. Run the two phases sequentially on the same dataset.Repeat the check-in and report-retrieval process during this phase. Ask the agent to compare with the higher-concurrency reports, substituting the new application name and start time. Compare measured throughput as well as latency: lower concurrency can reduce contention while also reducing the rate of completed work.

Reference measurements and limits

A reference run we performed produced the following workload-client totals. Each phase had a 12-minute measurement period after a 30-second ramp:Separate SQL observations showed normalized CPU around 22–23% during the higher-concurrency phase and around 8% during the lower-concurrency phase. Warehouse-update profiles showed average statement service time around 42–44 ms at higher concurrency and 6–7 ms at lower concurrency. These are observations from selected statistics windows rather than whole-run aggregates or Aegis measurements.Throughput fell substantially while the overall client p99 improved modestly. The runs were sequential on a changing dataset, used a laptop client, and were an exercise rather than an isolated capacity benchmark. Statement service latency, sampled contention time, and client transaction latency have different meanings and measurement windows, so compare like with like.
In this test, two completed check-ins during the lower-concurrency phase carried the earlier reports forward unchanged. Their as_of timestamps advanced, while both report bodies and created_at values still described the higher-concurrency phase. For this phase, the direct measurements above stand on their own, and Aegis’s analysis of it was unavailable.
If your reports are unchanged or do not cover the phase, record the gap. A new check-in ID indicates a new check-in, and each report’s changed and created_at fields show whether its content is new. Wait for an applicable report, or use your existing monitoring tools for the comparison.

Step 6. Check recovery and choose a next action

After the second workload exits, record its end time and verify through your normal monitoring tools that workload traffic subsides. Leave the connector running, allow time for idle observations, and retrieve reports after a later check-in.Confirm that the report contents cover the period after the stop time. In the reference test, direct SQL observations showed CPU returning to about 1.2%, while the first post-run MCP snapshot still carried the higher-concurrency reports. A later scheduled check-in produced reports describing an idle cluster with near-zero traffic and CPU around 1–3%, which confirmed recovery.Use what you learned to investigate a real workload’s conflicting transactions and application requirements. Before choosing a mitigation, see Reduce transaction contention and Troubleshoot lock contention.Retain the test logs and reports needed for your comparison. Remove the test data and deprovision dedicated test resources through your normal cleanup process when you no longer need them. Note that stopping the TPC-C runs via cockroach workload still leaves the database and the connector in place, and cloud cluster charges continue to accrue.

See also