Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql-statements, tidb-configuration-file: refine the document about expression index #6643

Merged
merged 29 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a0dca2e
*: remove expression index out of experimental feature. (#4641)
wjhuang2016 Oct 10, 2020
3262b79
init
wjhuang2016 Jul 8, 2021
9f2b77a
done
wjhuang2016 Aug 9, 2021
a76bdcc
Merge branch 'master' of github.com:pingcap/docs-cn into expression_i…
wjhuang2016 Aug 9, 2021
5b33eb9
lint
wjhuang2016 Aug 9, 2021
2d229c7
lint
wjhuang2016 Aug 9, 2021
08998d7
lint
wjhuang2016 Aug 9, 2021
1e84643
lint
wjhuang2016 Aug 9, 2021
b30b447
lint
wjhuang2016 Aug 9, 2021
3d308d7
1
wjhuang2016 Aug 9, 2021
4066262
1
wjhuang2016 Aug 9, 2021
e56bc3a
1
wjhuang2016 Aug 9, 2021
551ddd0
done
wjhuang2016 Aug 9, 2021
767b414
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
564c724
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
b9c6c03
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
9640c0e
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
08d2573
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
b00f4be
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
0f40558
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
2210a64
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
46c8098
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
48d6000
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
b6dd2fb
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
d90a4b9
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
0a1952b
fix
wjhuang2016 Aug 10, 2021
0b70f80
fix
wjhuang2016 Aug 10, 2021
f42d85a
Update sql-statements/sql-statement-create-index.md
wjhuang2016 Aug 10, 2021
56a2449
Merge branch 'master' into expression_index_ga
wjhuang2016 Aug 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions sql-statements/sql-statement-create-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ Query OK, 0 rows affected (0.31 sec)

## 表达式索引

> **注意:**
>
> 该功能目前为实验特性,不建议在生产环境中使用。

如果需要使用这一特性,在 [TiDB 配置文件](/tidb-configuration-file.md#allow-expression-index-从-v400-版本开始引入)中进行以下设置:

{{< copyable "sql" >}}

```sql
allow-expression-index = true
```

TiDB 不仅能将索引建立在表中的一个或多个列上,还可以将索引建立在一个表达式上。当查询涉及表达式时,表达式索引能够加速这些查询。

考虑以下查询:
Expand All @@ -183,7 +171,7 @@ CREATE INDEX idx ON t ((lower(name)));

维护表达式索引的代价比一般的索引更高,因为在插入或者更新每一行时都需要计算出表达式的值。因为表达式的值已经存储在索引中,所以当优化器选择表达式索引时,表达式的值就不需要再计算。因此,当查询速度比插入速度和更新速度更重要时,可以考虑建立表达式索引。

表达式索引的语法和限制与 MySQL 相同,是通过将索引建立在隐藏的虚拟生成列 (generated virtual column) 上来实现的。因此所支持的表达式继承了虚拟生成列的所有[限制](/generated-columns.md#生成列的局限性)。目前,建立了索引的表达式只有在 `FIELD` 子句、`WHERE` 子句和 `ORDER BY` 子句中时,优化器才能使用表达式索引。后续将支持 `GROUP BY` 子句。
表达式索引的语法和限制与 MySQL 相同,是通过将索引建立在隐藏的虚拟生成列 (generated virtual column) 上来实现的。因此所支持的表达式继承了虚拟生成列的所有[限制](/generated-columns.md#生成列的局限性)。

## 不可见索引

Expand Down
7 changes: 1 addition & 6 deletions tidb-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,4 @@ TiDB 服务状态相关配置。

## experimental
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete the ‘experimental' part? I don't think it will be used in the future.


experimental 部分为 TiDB 实验功能相关的配置。该部分从 v3.1.0 开始引入。

### `allow-expression-index` <span class="version-mark">从 v4.0.0 版本开始引入</span>

+ 用于控制是否能创建表达式索引。
+ 默认值:false
experimental 部分为 TiDB 实验功能相关的配置。该部分从 v3.1.0 开始引入。目前暂无相关配置项。