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: v2.1/explain.md
+6-4
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,8 @@ Using `EXPLAIN`'s output, you can optimize your queries by taking the following
38
38
39
39
- Queries with fewer levels execute more quickly. Restructuring queries to require fewer levels of processing will generally improve performance.
40
40
41
+
- To view the distributed SQL query plan with execution statistics, use `EXPLAIN ANALYZE (DISTSQL)`.
42
+
41
43
- Avoid scanning an entire table, which is the slowest way to access data. You can avoid this by [creating indexes](indexes.html) that contain at least one of the columns that the query is filtering in its `WHERE` clause.
42
44
43
45
You can find out if your queries are performing entire table scans by using `EXPLAIN` to see which:
@@ -60,14 +62,14 @@ The user requires the appropriate [privileges](privileges.html) for the statemen
60
62
61
63
Parameter | Description
62
64
-----------|-----------
63
-
`ANALYZE` | Carry out the command and show execution statistics.
65
+
`ANALYZE` | <spanclass="version-tag">New in v2.1:</span> Execute the command and show execution statistics.
64
66
`EXPRS` | Include the SQL expressions that are involved in each processing stage.
65
67
`QUALIFY` | Include table names when referencing columns, which might be important to verify the behavior of joins across tables with the same column names.<br/><br/>To list qualified names, `QUALIFY` requires you to include the `EXPRS` option.
66
68
`METADATA` | Include the columns each level uses in the **Columns** column, as well as **Ordering** detail.
67
69
`VERBOSE` | Imply the `EXPRS`, `METADATA`, and `QUALIFY` options.
68
70
`TYPES` | Include the intermediate [data types](data-types.html) CockroachDB chooses to evaluate intermediate SQL expressions. <br/><br/>`TYPES` also implies `METADATA` and `EXPRS` options.
69
-
`OPT` | Display a query plan tree if the query will be run with the [cost-based optimizer](sql-optimizer.html). If it returns `pq: unsupported statement: *tree.Insert`, the query will not be run with the cost-based optimizer and will be run with the heuristic planner.
70
-
`DISTSQL` | Provide a link that displays a distributed SQL plan tree.
71
+
`OPT` | <spanclass="version-tag">New in v2.1:</span> Display a query plan tree if the query will be run with the [cost-based optimizer](sql-optimizer.html). If it returns `pq: unsupported statement: *tree.Insert`, the query will not be run with the cost-based optimizer and will be run with the heuristic planner.
72
+
`DISTSQL` | <spanclass="version-tag">New in v2.1:</span> Provide a link that displays a distributed SQL plan tree.
71
73
`explainable_stmt` | The [statement](#explainable-statements) you want details about.
72
74
73
75
{{site.data.alerts.callout_danger}}<code>EXPLAIN</code> also includes other modes besides query plans that are useful only to CockroachDB developers, which are not documented here.{{site.data.alerts.end}}
@@ -369,7 +371,7 @@ The query above will not be run with the cost-based optimizer.
369
371
370
372
### `DISTSQL` option
371
373
372
-
<spanclass="version-tag">New in v2.1:</span> The `DISTSQL` option provides a link to a distributed query plan tree and point your browser to the URL provided:
374
+
<spanclass="version-tag">New in v2.1:</span> The `DISTSQL` option provides a link to a distributed query plan tree:
0 commit comments