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.
- Understand transaction contention: run a small TPC-C workload, read Aegis’s analysis of hot-row contention, reduce concurrency, and compare the two phases.
- Review and apply an index recommendation: create a table without a secondary index, generate a repeated full-scan query, review Aegis’s index recommendation, apply the index, and verify the effect.
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
cockroachbinary and checkcockroach version. Each example specifies its workload commands. For more information, seecockroach 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
PGURLto this test cluster’s connection URL, initially usingdefaultdb. Omit the password and retainsslmode=verify-fulland the correctsslrootcertpath. Supply the workload credential throughPGPASSWORDusing 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
ccloudCLI to obtain these values.ccloud cluster sql --connection-url {cluster_name}returns a connection URL that already includessslmode=verify-fulland the path to the downloaded CA certificate, andccloud cluster user createcreates the workload SQL user. For more information, see and .
- Transaction contention
- Index recommendation
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.Checkcockroach 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: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:Step 2. Capture an idle baseline
After initialization finishes, select the intended Aegis instance over MCP withlist_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:This is a contention exercise rather than a compliant TPC-C benchmark or a capacity-sizing test.
Step 4. Interpret the contention evidence
Ask your agent to compare the reports with the baseline using a prompt like the following:{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:--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.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 viacockroach workload still leaves the database and the connector in place, and cloud cluster charges continue to accrue.
