You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/current/v25.4/troubleshoot-query-plan-regressions.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ For any given SQL statement, if the [cost-based optimizer]({% link {{page.versio
12
12
13
13
## Before you begin
14
14
15
-
-[Understand how the cost-based optimizer chooses query plans]({% link {{page.version.version}}/cost-based-optimizer.md %}) based on table statistics, and how those statistics are refreshed.
15
+
-[Understand how the cost-based optimizer chooses query plans]({% link {{page.version.version}}/cost-based-optimizer.md %}) based on table statistics and how those statistics are refreshed.
16
16
17
17
## What to look out for
18
18
19
19
Query plan regressions only increase the execution time of SQL statements that use the affected plan. This means that the overall service latency of the cluster will only be affected during the execution of statements that are run with the problematic query plan.
20
20
21
21
As a result, these latency spikes can be hard to identify. For example, if the problematic plan only affects a query that's run on an infrequent, ad-hoc basis, it might be difficult to notice a pattern among the graphs on the [**Metrics** page]({% link {{page.version.version}}/ui-overview.md %}#metrics).
22
22
23
-
To identify and fix query plan regressions, you must determine whether certain statement executions are associated with increased service latency. Next, check whether the statement’s query plan has changed. Finally, use CockroachDB's tools to understand why the query plan changed, so you can confirm that the change directly caused the latency increase.
23
+
To identify and fix query plan regressions, you must determine whether certain statement executions are associated with increased service latency. Next, check whether the statement’s query plan has changed. Finally, use CockroachDB tools to understand why the query plan changed, so you can confirm that the change directly caused the latency increase.
24
24
25
25
## Troubleshooting
26
26
@@ -52,7 +52,7 @@ Knowing what service latency to expect, based on your cluster's usual activity,
52
52
53
53
### Step 2. Identify high-latency statements
54
54
55
-
One way to track down query plan regressions is to identify SQL statements with relatively high execution latency. These statements might be associated with a latency increase.
55
+
One way to track down query plan regressions is to identify SQL statements with relatively high execution latency. These statements may be associated with increased latency.
56
56
57
57
1. Go to the [**SQL Activity** > **Statements** page]({% link {{page.version.version}}/ui-statements-page.md %}) in the DB Console.
58
58
2. If you identified specific time intervals in Step 1, use the time interval selector to define a custom interval. Click **Apply**.
@@ -78,7 +78,7 @@ For each suspect SQL statement, determine whether the high latency is caused by
78
78
5. Note which query plan was in use just before the latency increase, and record the values in the **Plan Gist**, **Average Execution Time**, and **Average Rows Read** columns.
79
79
6. Compare the query plans.
80
80
81
-
If the newer plan matches the older plan (i.e., it has the same **Plan Gist**), there was no query plan regression.
81
+
If the newer plan matches the older plan (that is, it has the same **Plan Gist**), there was no query plan regression.
82
82
83
83
If the newer plan differs from the older plan, the query plan has changed:
84
84
@@ -88,7 +88,7 @@ If the newer plan differs from the older plan, the query plan has changed:
88
88
89
89
#### Multiple valid query plans
90
90
91
-
If multiple query plans were used before and after the latency increase, the SQL statement may have multiple valid query plans. This can occur when the optimizer chooses a plan based on literal values in the SQL query, those replaced by the "_" placeholder in the statement fingerprint. The optimizer may decide that different plans are better for different literal values.
91
+
If multiple query plans were used before and after the latency increase, the SQL statement may have multiple valid query plans. This can occur when the optimizer chooses a plan based on literal values in the SQL query, those replaced by the "_" placeholder in the statement fingerprint. The optimizer may decide that different plans are better for different literal values.
92
92
93
93
With multiple valid query plans, you’re not just looking for a plan change, but for a shift in the _distribution of plans_ used for the statement.
94
94
@@ -108,7 +108,7 @@ For any query plans whose increased execution time seems suspicious, investigate
108
108
109
109
#### Determine if the table indexes changed
110
110
111
-
1. Check the **Used Indexes** column for both the older and newer query plans. If these aren't the same, it's likely that the creation or deletion of an index resulted in a change to the statement's query plan.
111
+
1. Check the **Used Indexes** column for both the older and newer query plans. If these differ, it's likely that the creation or deletion of an index resulted in a change to the statement's query plan.
112
112
2. In the **Explain Plans** tab, click the **Plan Gist** of the more recent plan to view its details. Identify the table(s) used in the initial "scan" step of the plan.
113
113
3. In your SQL client, run `SHOW INDEXES FROM <table_name>;` for each of those tables.
114
114
4. Make sure that the query plan is using a table index that makes sense, given the query and the table's full set of indexes.
0 commit comments