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

Update how to connect TiDB by MySQL Client and the limitations of the global indexes #19345

Merged
merged 11 commits into from
Dec 25, 2024
14 changes: 14 additions & 0 deletions develop/dev-guide-connect-to-tidb.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ sudo yum install mysql
mysql --host <tidb_server_host> --port 4000 -u root -p --comments
```

macOS 的 MySQL v9.0 Client 无法正确加载 `mysql_native_password` 插件,导致连接 TiDB 时报错 `ERROR 2059 (HY000): Authentication plugin 'mysql_native_password' cannot be loaded`。为解决该问题,建议安装并使用 MySQL v8.0 Client 链接 TiDB 。安装命令如下:
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

```shell
brew install mysql-client@8.0
brew unlink mysql
brew link mysql-client@8.0
```

如果仍然遇到问题,可以尝试指定 MySQL v8.0 Client 的安装路径来使用 MySQL v8.0 Client 连接 TiDB。安装命令如下:
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

```shell
/opt/homebrew/opt/mysql-client@8.0/bin/mysql --comments --host ${YOUR_IP_ADDRESS} --port ${YOUR_PORT_NUMBER} -u ${your_user_name} -p
```

hfxsd marked this conversation as resolved.
Show resolved Hide resolved
</div>

<div label="MySQL Shell">
Expand Down
4 changes: 3 additions & 1 deletion partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,9 @@ ALTER TABLE t1 PARTITION BY HASH (col1) PARTITIONS 3 UPDATE INDEXES (uidx12 LOCA

- 如果索引定义中未显式指定 `GLOBAL` 关键字,TiDB 将默认创建局部索引 (Local Index)。
- `GLOBAL` 和 `LOCAL` 关键字仅适用于分区表,对非分区表没有影响。即在非分区表中,全局索引和局部索引之间没有区别。
- DDL 操作如 `ADD PARTITION`、`DROP PARTITION`、`TRUNCATE PARTITION`、`REORGANIZE PARTITION`、`SPLIT PARTITION` 和 `EXCHANGE PARTITION` 等也会触发对全局索引的更新,这些 DDL 的执行结果将在全局索引更新完成后才会返回。因此,这可能会延迟一些通常需要快速完成的 DDL 的操作,如数据归档操作(`EXCHANGE PARTITION`、`TRUNCATE PARTITION` 和 `DROP PARTITION`)。而如果没有全局索引,这些 DDL 操作可以立即执行完成。
- 当前仅支持创建唯一全局索引 (Unique Global Index),如果需要对非唯一的列创建全局索引,该全局索引需要包含分区建形成复合索引,且非唯一的列排在前面。例如,非唯一的列为 `col3`,分区建为 `col1`,则可以通过执行 `ALTER TABLE ... ADD UNIQUE KEY(col3,col1) GLOBAL;` 为非唯一列 `col3` 创建全局索引。
- DDL 操作如 `ADD PARTITION`、`DROP PARTITION`、`TRUNCATE PARTITION`、`REORGANIZE PARTITION`,`EXCHANGE PARTITION` 等也会触发对全局索引的更新,这些 DDL 的执行结果将在全局索引更新完成后才会返回。因此,这可能会延迟一些通常需要快速完成的 DDL 的操作,如数据归档操作(`TRUNCATE PARTITION` 和 `DROP PARTITION`)。而如果没有全局索引,这些 DDL 操作可以立即执行完成。
- 创建了全局索引的表不支持 `EXCHANGE PARTITION`。
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
- 默认情况下,分区表的主键为聚簇索引,且必须包含分区键。如果要求主键不包含分区建,可以在建表时显式指定主键为非聚簇的全局索引,例如:`PRIMARY KEY(col1, col2) NONCLUSTERED GLOBAL`。
- 如果在表达式列上添加了全局索引,或者一个全局索引同时也是前缀索引(如 `UNIQUE KEY idx_id_prefix (id(10)) GLOBAL`),你需要为该全局索引手动收集统计信息。

Expand Down
Loading