Skip to content

Commit

Permalink
Merge branch 'master' into pr/9787
Browse files Browse the repository at this point in the history
  • Loading branch information
TomShawn committed Aug 5, 2022
2 parents 02f9939 + a565595 commit 7c0139f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion basic-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This document lists the features supported in each TiDB version. Note that suppo
| [Auto increment](/auto-increment.md) | Y | Y | Y | Y | Y | Y | Y | Y |
| [Auto random](/auto-random.md) | Y | Y | Y | Y | Y | Y | Y | Y |
| [DDL algorithm assertions](/sql-statements/sql-statement-alter-table.md) | Y | Y | Y | Y | Y | Y | Y | Y |
| [Multi-schema change: add columns](/system-variables.md#tidb_enable_change_multi_schema) | Experimental | Experimental | Experimental | Experimental | Experimental | Experimental | Experimental | Experimental |
| Multi-schema change: add columns | Experimental | Experimental | Experimental | Experimental | Experimental | Experimental | Experimental | Experimental |
| [Change column type](/sql-statements/sql-statement-modify-column.md) | Y | Y | Y | Y | Y | Y | N | N |
| [Temporary tables](/temporary-tables.md) | Y | Y | Y | Y | N | N | N | N |

Expand Down
4 changes: 4 additions & 0 deletions develop/dev-guide-use-common-table-expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ First, check out the books written by the author (ID is `2299112019`) in the CTE

Note that the query in `books_authored_by_rm` executes only once, and then TiDB creates a temporary space to cache its result. When the queries in `books_with_average_ratings` and `books_with_orders` refer to `books_authored_by_rm`, TiDB gets its result directly from this temporary space.

> **Tip:**
>
> If the efficiency of the default CTE queries is not good, you can use the [`MERGE()`](/optimizer-hints.md#merge) hint to expand the CTE subquery to the outer query to improve the efficiency.
### Recursive CTE

Recursive CTE can be defined using the following syntax:
Expand Down
21 changes: 21 additions & 0 deletions optimizer-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,27 @@ SHOW WARNINGS;
+---------+------+-------------------------------------------------------------------------------------------------------------------+
```

### MERGE()

Using the `MERGE()` hint in queries with common table expressions (CTE) can disable the materialization of the subqueries and expand the subquery inlines into CTE. This hint is only applicable to non-recursive CTE. In some scenarios, using `MERGE()` brings higher execution efficiency than the default behavior of allocating a temporary space. For example, pushing down query conditions or in nesting CTE queries:

```sql
-- Uses the hint to push down the predicate of the outer query.
WITH CTE AS (SELECT /*+ MERGE() */ * FROM tc WHERE tc.a < 60) SELECT * FROM CTE WHERE CTE.a < 18;

-- Uses the hint in a nested CTE query to expand a CTE inline into the outer query.
WITH CTE1 AS (SELECT * FROM t1), CTE2 AS (WITH CTE3 AS (SELECT /*+ MERGE() */ * FROM t2), CTE4 AS (SELECT * FROM t3) SELECT * FROM CTE3, CTE4) SELECT * FROM CTE1, CTE2;
```

> **Note:**
>
> `MERGE()` is only applicable to simple CTE queries. It is not applicable in the following situations:
>
> - [Recursive CTE](/develop/dev-guide-use-common-table-expression.md#recursive-cte)
> - Subqueries with inlines that cannot be expanded, such as aggregate operators, window functions, and `DISTINCT`.
>
> When the number of CTE references is too high, the query performance might be lower than the default materialization behavior.
## Hints that take effect in the whole query

This category of hints can only follow behind the **first** `SELECT`, `UPDATE` or `DELETE` keyword, which is equivalent to modifying the value of the specified system variable when this query is executed. The priority of the hint is higher than that of existing system variables.
Expand Down
6 changes: 6 additions & 0 deletions tikv-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,12 @@ Configuration items related to Raftstore.
+ Default value: `1MB`
+ Minimum value: `0`

### `report-min-resolved-ts-interval` <span class="version-mark">New in v6.2.0</span>

+ If you set this configuration value greater than `0`, TiKV checks the minimum ResolvedTS regularly for all Regions on the current node and reports the information to PD.
+ Default value: `0s`
+ Minimum value: `0s`

## Coprocessor

Configuration items related to Coprocessor.
Expand Down

0 comments on commit 7c0139f

Please sign in to comment.