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
* Plan ditribution over time graph docs
* fixed links
* added new screenshot and edited old ones
* Revert non-v26.2 files (feature is v26.2-only)
* removed detail about time window duration
* Update src/current/_includes/v26.2/ui/statement-details.md
Co-authored-by: Joe Lodin <joe.lodin@cockroachlabs.com>
* fixed plan gist bold/capitalization
---------
Co-authored-by: Joe Lodin <joe.lodin@cockroachlabs.com>
The **Plan Distribution Over Time** graph displays the execution counts for query plans within the selected time interval. If multiple query plans were used during a given time period, the plans are stacked and represented by a different color to compare their relative execution counts. The key below the graph indicates the plan gist associated with each color. More information about these query plans can be found in the [plan table](#plan-table).
85
+
86
+
This graph helps illustrate changes in the distribution of query plans chosen by the [cost-based optimizer]({{ link_prefix }}cost-based-optimizer.html) for this SQL statement. This can be useful for [troubleshooting query plan regressions]({{ link_prefix }}troubleshoot-query-plan-regressions.html#multiple-valid-query-plans).
87
+
88
+
<imgsrc="{{ 'images/v26.2/ui_plan_distribution_over_time.png' | relative_url }}"alt="Plan distribution over time graph"style="border:1pxsolid#eee;max-width:100%" />
Copy file name to clipboardExpand all lines: src/current/v25.4/troubleshoot-query-plan-regressions.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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 (that is, 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
@@ -102,22 +102,22 @@ If you couldn’t identify a specific moment when latency increased, you won’t
102
102
103
103
For any query plans whose increased execution time seems suspicious, investigate further to understand why the plan changed.
104
104
105
-
1. In the **Explain Plans** tab, click the **Plan Gist** of the more recent plan to view its details.
105
+
1. In the **Explain Plans** tab, click on the plan gist of the more recent plan to view its details.
106
106
2. Click on **All Plans** above to return to the full list.
107
-
3. Click on the Plan Gist of the previous plan to inspect it in more detail. Compare the two plans to understand what changed. They may use different indexes. They may also scan different parts of the table or use different join strategies.
107
+
3. Click on the plan gist of the previous plan to inspect it in more detail. Compare the two plans to understand what changed. They may use different indexes. They may also scan different parts of the table or use different join strategies.
108
108
109
109
#### Determine if the table indexes changed
110
110
111
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
-
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.
112
+
2. In the **Explain Plans** tab, click on 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.
115
115
116
116
The new index may be well-chosen, but the schema change could have triggered a statistics refresh that caused the issue. It's also possible that the new index is not ideal. Consider how and when the table is queried to determine whether the index should be reconsidered. [Check the **Insights** page for index recommendations]({% link {{ page.version.version }}/ui-insights-page.md %}#suboptimal-plan), and read more about [secondary index best practices]({% link {{ page.version.version }}/schema-design-indexes.md %}#best-practices).
117
117
118
118
#### Determine if the table statistics changed
119
119
120
-
1. In the **Explain Plans** tab, click the Plan Gist of the more recent plan to view its details. Identify the table used in the initial "scan" step of the plan.
120
+
1. In the **Explain Plans** tab, click on the plan gist of the more recent plan to view its details. Identify the table used in the initial "scan" step of the plan.
121
121
2. In your SQL client, run `SHOW STATISTICS FOR TABLE <table_name>;` using that table name.
122
122
123
123
The results will include statistics that were collected for each column in that table. The value in the "created" column of these results tells you when the statistics were collected. Compare the statistics of each table column across multiple timestamps. A change in the values of `row_count`, `distinct_count`, `null_count`, or other statistics may have affected planning. If the timestamp of the new statistics creation is associated with the time that the query plan changed, there may be a causal relationship between the two.
Copy file name to clipboardExpand all lines: src/current/v26.1/troubleshoot-query-plan-regressions.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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 (that is, 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
@@ -102,22 +102,22 @@ If you couldn’t identify a specific moment when latency increased, you won’t
102
102
103
103
For any query plans whose increased execution time seems suspicious, investigate further to understand why the plan changed.
104
104
105
-
1. In the **Explain Plans** tab, click the **Plan Gist** of the more recent plan to view its details.
105
+
1. In the **Explain Plans** tab, click on the plan gist of the more recent plan to view its details.
106
106
2. Click on **All Plans** above to return to the full list.
107
-
3. Click on the Plan Gist of the previous plan to inspect it in more detail. Compare the two plans to understand what changed. They may use different indexes. They may also scan different parts of the table or use different join strategies.
107
+
3. Click on the plan gist of the previous plan to inspect it in more detail. Compare the two plans to understand what changed. They may use different indexes. They may also scan different parts of the table or use different join strategies.
108
108
109
109
#### Determine if the table indexes changed
110
110
111
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
-
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.
112
+
2. In the **Explain Plans** tab, click on 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.
115
115
116
116
The new index may be well-chosen, but the schema change could have triggered a statistics refresh that caused the issue. It's also possible that the new index is not ideal. Consider how and when the table is queried to determine whether the index should be reconsidered. [Check the **Insights** page for index recommendations]({% link {{ page.version.version }}/ui-insights-page.md %}#suboptimal-plan), and read more about [secondary index best practices]({% link {{ page.version.version }}/schema-design-indexes.md %}#best-practices).
117
117
118
118
#### Determine if the table statistics changed
119
119
120
-
1. In the **Explain Plans** tab, click the Plan Gist of the more recent plan to view its details. Identify the table used in the initial "scan" step of the plan.
120
+
1. In the **Explain Plans** tab, click on the plan gist of the more recent plan to view its details. Identify the table used in the initial "scan" step of the plan.
121
121
2. In your SQL client, run `SHOW STATISTICS FOR TABLE <table_name>;` using that table name.
122
122
123
123
The results will include statistics that were collected for each column in that table. The value in the "created" column of these results tells you when the statistics were collected. Compare the statistics of each table column across multiple timestamps. A change in the values of `row_count`, `distinct_count`, `null_count`, or other statistics may have affected planning. If the timestamp of the new statistics creation is associated with the time that the query plan changed, there may be a causal relationship between the two.
Copy file name to clipboardExpand all lines: src/current/v26.2/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
@@ -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 (that is, 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
@@ -92,7 +92,7 @@ If multiple query plans were used before and after the latency increase, the SQL
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
95
-
-Look at the query plans that were used in the time interval after the latency increase. Note the values in the **Execution Count**column for each plan. Repeat the process for the interval before the latency increase. This will let you know not only if the same query plans were being used during both intervals, but also if their distributions changed. If the distribution shifts toward a plan with higher average execution time, it may indicate a query plan regression.
95
+
-On the **Explain Plans**tab, refer to the [**Plan Distribution Over Time**]({% link {{ page.version.version }}/ui-statements-page.md %}#plan-distribution-over-time) graph. Note the distribution of query plans both before and after the latency increase. If the distribution shifts toward a plan with higher average execution time, it may indicate a query plan regression.
96
96
97
97
{{site.data.alerts.callout_success}}
98
98
If you couldn’t identify a specific moment when latency increased, you won’t have a clear "before" and "after" to compare. In this case, it’s still helpful to have a general sense of when the increase occurred (using the methods from Step 1) even if the range spans several hours. You can then use the above methods (in Step 3) to compare query plans on a rolling basis by changing the custom time interval to consecutive hour-long intervals. This approach can help identify the specific interval when the latency spike occurred.
@@ -102,22 +102,22 @@ If you couldn’t identify a specific moment when latency increased, you won’t
102
102
103
103
For any query plans whose increased execution time seems suspicious, investigate further to understand why the plan changed.
104
104
105
-
1. In the **Explain Plans** tab, click the **Plan Gist** of the more recent plan to view its details.
105
+
1. In the **Explain Plans** tab, click on the plan gist of the more recent plan to view its details.
106
106
2. Click on **All Plans** above to return to the full list.
107
-
3. Click on the Plan Gist of the previous plan to inspect it in more detail. Compare the two plans to understand what changed. They may use different indexes. They may also scan different parts of the table or use different join strategies.
107
+
3. Click on the plan gist of the previous plan to inspect it in more detail. Compare the two plans to understand what changed. They may use different indexes. They may also scan different parts of the table or use different join strategies.
108
108
109
109
#### Determine if the table indexes changed
110
110
111
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
-
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.
112
+
2. In the **Explain Plans** tab, click on 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.
115
115
116
116
The new index may be well-chosen, but the schema change could have triggered a statistics refresh that caused the issue. It's also possible that the new index is not ideal. Consider how and when the table is queried to determine whether the index should be reconsidered. [Check the **Insights** page for index recommendations]({% link {{ page.version.version }}/ui-insights-page.md %}#suboptimal-plan), and read more about [secondary index best practices]({% link {{ page.version.version }}/schema-design-indexes.md %}#best-practices).
117
117
118
118
#### Determine if the table statistics changed
119
119
120
-
1. In the **Explain Plans** tab, click the Plan Gist of the more recent plan to view its details. Identify the table used in the initial "scan" step of the plan.
120
+
1. In the **Explain Plans** tab, click on the plan gist of the more recent plan to view its details. Identify the table used in the initial "scan" step of the plan.
121
121
2. In your SQL client, run `SHOW STATISTICS FOR TABLE <table_name>;` using that table name.
122
122
123
123
The results will include statistics that were collected for each column in that table. The value in the "created" column of these results tells you when the statistics were collected. Compare the statistics of each table column across multiple timestamps. A change in the values of `row_count`, `distinct_count`, `null_count`, or other statistics may have affected planning. If the timestamp of the new statistics creation is associated with the time that the query plan changed, there may be a causal relationship between the two.
0 commit comments