- SQL statement performance: This is the most common cause of performance problems and where you should start.
- Schema design: Depending on your SQL schema and the data access patterns of your workload, you may need to make changes to avoid creating or .
- Cluster topology: As a distributed system, CockroachDB requires you to trade off latency vs. resiliency. This requires choosing the right cluster topology for your needs.
SQL statement performance rules
To get good SQL statement performance, follow these rules:- . If your application is scanning more rows than necessary for a given statement, it’s going to be difficult to scale.
- . Your statement should use an index on the columns in the
WHEREclause. You want to avoid the performance hit of a full table scan. - . Depending on the relative sizes of the tables you are querying, the type of may be important. You should only rarely need to specify the join type because the should pick the best-performing join type if you add the right indexes as described in Rule 2. However, in some circumstances you may want to specify a .
Schema design
If you are following the instructions in the SQL performance section and still not getting the performance you want, you may need to look at your schema design and data access patterns to make sure that you are not:- Introducing transaction contention. For methods for diagnosing and mitigating transaction contention, see .
- Creating hotspots in your cluster. For methods for detecting and eliminating hotspots, refer to .

