当前位置:网站首页>Speed adjustment of tidb DDL
Speed adjustment of tidb DDL
2022-06-11 17:33:00 【On the way to data communication】
One 、 Description of the environment
| ip | Components | To configure |
|---|---|---|
| 192.168.1.1 | tidb、pd、tikv | 2c4g |
| 192.168.1.2 | tidb、pd、tikv | 2c4g |
| 192.168.1.3 | tidb、pd、tikv | 2c4g |
Two 、 Experimental environment preparation
1. Build table
# ddl_1,ddl_2,ddl_3 The table structure is consistent
CREATE TABLE `ddl_1` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`z_name` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
`z_info` varchar(30) COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
2. Insert
import pymysql
conn = pymysql.Connect()
cur = conn.cursor()
# ddl_1,ddl_2,ddl_3 insert data
sql_str = 'insert into ddl_2(z_name, z_info) values("csdfsdfsdfsda", "qwwerwerisdfnsdvj vsd")'
for i in range(1000):
sql_str = sql_str + ',("csdfsdfsdfsda", "qwwerwerisdfnsdvj vsd")'
for i in range(1000):
print(i)
cur.execute(sql_str)
conn.commit()
conn.close()
3. View table information
mysql> show table ddl_2 regions\G
*************************** 1. row ***************************
REGION_ID: 1149
START_KEY: t_80_
END_KEY: t_85_
LEADER_ID: 1152
LEADER_STORE_ID: 5
PEERS: 1150, 1151, 1152
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 108
APPROXIMATE_KEYS: 1346062
1 row in set (0.02 sec)
mysql> show table ddl_1 regions\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: t_85_
END_KEY:
LEADER_ID: 3
LEADER_STORE_ID: 1
PEERS: 3, 6, 7
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 0
APPROXIMATE_SIZE(MB): 97
APPROXIMATE_KEYS: 1013491
1 row in set (0.10 sec)
mysql> show table ddl_3 regions\G
*************************** 1. row ***************************
REGION_ID: 2
START_KEY: t_89_
END_KEY:
LEADER_ID: 3
LEADER_STORE_ID: 1
PEERS: 3, 6, 7
SCATTERING: 0
WRITTEN_BYTES: 0
READ_BYTES: 93093000
APPROXIMATE_SIZE(MB): 101
APPROXIMATE_KEYS: 1031510
1 row in set (0.01 sec)
4. Add index
mysql> alter table ddl_1 add index idx_z_info(z_info);
Query OK, 0 rows affected (2 min 16.17 sec)
set global tidb_ddl_reorg_batch_size=1024;
mysql> alter table ddl_2 add index idx_z_info(z_info);
Query OK, 0 rows affected (1 min 44.53 sec)
set global tidb_ddl_reorg_worker_cnt=8;
mysql> alter table ddl_3 add index idx_z_info(z_info);
Query OK, 0 rows affected (1 min 40.01 sec)
5. control ddl Related parameters of
| Parameters | significance |
|---|---|
| ddl_slow_threshold | Time consuming beyond this threshold DDL The operation will be output to the log |
| tidb_ddl_error_count_limit | Used to control DDL Number of retries for operation failure . After the number of failed retries exceeds the value of this parameter , Will cancel the error DDL operation |
| tidb_ddl_reorg_priority | Used to set ADD INDEX operation re-organize Execution priority of the phase , Can be set to PRIORITY_LOW/PRIORITY_NORMAL/PRIORITY_HIGH |
| tidb_ddl_reorg_batch_size | Used to set DDL operation re-organize Stage batch size, such as ADD INDEX operation , Need to backfill index data , By concurrency tidb_ddl_reorg_worker_cnt individual worker Backfill data together , Every worker With batch Backfill per unit |
| tidb_ddl_reorg_worker_cnt | Used to set DDL operation re-organize Concurrency of phases |
3、 ... and 、 Comparison conclusion
| tidb_ddl_reorg_batch_size | tidb_ddl_reorg_worker_cnt | execution time | Consume cpu |
|---|---|---|---|
| 256 | 4 | 136s | 102% |
| 1024 | 4 | 104s | 128% |
| 1024 | 8 | 100s | 130% |
Conclusion : From the test results , The bigger tidb_ddl_reorg_batch_size, The bigger tidb_ddl_reorg_worker_cnt Faster execution time , At the same time, it will bring higher cpu
边栏推荐
- Don't you understand the design and principle of thread pool? Break it up and crush it. I'll teach you how to design the thread pool
- 删除链表的倒数第N个节点---2022/02/22
- tidb-cdc创建任务报错 Unknown or incorrect time zone
- There are so many open source projects. This time, I'll show you the differences between different versions and understand the meaning of alpha version, beta version and RC version
- Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“
- Semaphore PV operation of process interaction and its code implementation
- R language mice package error in terms Formula (TMP, simplify = true): the model formula in extractvars is incorrect
- 04_ Feature engineering feature selection
- 搜狐全员遭诈骗,暴露哪些问题?
- 端口规划与APJ
猜你喜欢

which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod

ffmpeg奇偶场帧Interlace progressive命令和代码处理

Chapter II relational database

Dynamic: capturing network dynamics using dynamic graph representation learning

活动 | Authing 首次渠道合作活动圆满落幕

通过Xshell连接有跳板机/堡垒机的服务器

Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“

DFS and BFS notes (I) breadth first search based on C language

合并K个升序链表---2022/02/26

Authing biweekly news: online application market (5.10-5.22)
随机推荐
[online problem] timeout waiting for connection from pool
What is the minimum change price of PTA futures? How can PTA futures be safe?
which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_ mod
信息安全数学基础 Chapter 3——有限域(一)
TestPattern error
信息安全数学基础 Chapter 4——二次剩余与方根
Talk about the interview questions of the collection
Qlineedit set input mask
搜狐全员遭诈骗,暴露哪些问题?
mysql 大表的拆分方式
信息安全数学基础 Chapter 3——有限域(二)
Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?
05_特征工程—降维
6-6 批量求和(*)
Cs0006 C failed to find metadata file "c:\users\... Problem
ffmpeg硬编解码 Inter QSV
搜狐全員遭詐騙,暴露哪些問題?
6-1 从文件读取字符串(*)
Activity | authing's first channel cooperation activity came to a successful conclusion
Mathematical basis of information security Chapter 1 - Division