1 Mysql5.6 1.1 Related parameters MySQL 5.6 adds three parameters: innodb_undo_directory, innodb_undo_logs, and innodb_undo_tablespaces, which can move the undo log from ibdata1 and store it separately.
Default parameters: mysql> show variables like '%undo%'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | innodb_undo_directory | . | | innodb_undo_logs | 128 | | innodb_undo_tablespaces | 0 | +-------------------------+-------+
Instance initialization is to modify innodb_undo_tablespaces: mysql_install_db ...... --innodb_undo_tablespaces $ ls ... undo001 undo002 undo003
1.2 Usage Before initializing the instance, we only need to set the innodb_undo_tablespaces parameter (recommended to be greater than or equal to 3) to set the undo log to a separate undo tablespace. If you need to put the undo log on a faster device, you can set the innodb_undo_directory parameter, but we generally don't do this because SSDs are very popular now. innodb_undo_logs can be set to 128 by default. Undo logs can be stored outside of ibdata. But this feature is still useless:
1.3 Large Transaction Testing mysql> create table test.tbl( id int primary key auto_increment, name varchar(200)); Query OK, 0 rows affected (0.03 sec) mysql> start transaction; Query OK, 0 rows affected (0.00 sec) mysql> insert into test.tbl(name) values(repeat('1',00)); Query OK, 1 row affected (0.00 sec) mysql> insert into test.tbl(name) select name from test.tbl; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 ... mysql> insert into test.tbl(name) select name from test.tbl; Query OK, 2097152 rows affected (24.84 sec) Records: 2097152 Duplicates: 0 Warnings: 0 mysql> commit; Query OK, 0 rows affected (7.90 sec) Observe that the undolog has begun to expand! The space is not reclaimed after the transaction is committed. $ du -sh undo* 10M undo001 69M undo002 10M undo003 2 Mysql5.7 5.7 introduced online truncate undo tablespace 2.1 Related parameters Necessary conditions:
Startup parameters:
2.2 Cleaning process
2.3 Performance Recommendations The easiest way to avoid a performance hit when truncating a tablespace is to increase the number of undo tablespaces. 2.4 Large Transaction Testing Configure 8 undo tablespaces, innodb_purge_rseg_truncate_frequency=10 mysqld --initialize ... --innodb_undo_tablespaces=8 Start Testing mysql> show global variables like '%undo%'; +--------------------------+------------+ | Variable_name | Value | +--------------------------+------------+ | innodb_max_undo_log_size | 1073741824 | | innodb_undo_directory | ./ | | innodb_undo_log_truncate | ON | | innodb_undo_logs | 128 | | innodb_undo_tablespaces | 8 | +--------------------------+------------+ mysql> select @@innodb_purge_rseg_truncate_frequency; +----------------------------------------+ | @@innodb_purge_rseg_truncate_frequency | +----------------------------------------+ | 10 | +----------------------------------------+ select @@innodb_max_undo_log_size; +----------------------------+ | @@innodb_max_undo_log_size | +----------------------------+ |10485760| +----------------------------+ mysql> create table test.tbl( id int primary key auto_increment, name varchar(200)); Query OK, 0 rows affected (0.03 sec) mysql> start transaction; Query OK, 0 rows affected (0.00 sec) mysql> insert into test.tbl(name) values(repeat('1',00)); Query OK, 1 row affected (0.00 sec) mysql> insert into test.tbl(name) select name from test.tbl; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 ... mysql> insert into test.tbl(name) select name from test.tbl; Query OK, 2097152 rows affected (24.84 sec) Records: 2097152 Duplicates: 0 Warnings: 0 mysql> commit; Query OK, 0 rows affected (7.90 sec) The undo tablespace is successfully recovered after expanding to 100MB+
3 Reference https://dev.mysql.com/doc/ref... Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Implementation steps for building Webpack5-react scaffolding from scratch (with source code)
>>: Summary of how to add root permissions to users in Linux
Using padding-top percentage can achieve a fixed ...
At the very beginning, let's talk about what ...
Table of contents Create a global shared content ...
In previous development, we used the default attr...
Problem description: The following error message ...
The simple installation configuration of mysql5.7...
Table of contents Preface 1. What are Mixins? 2. ...
To draw a table in HTML, use the table tag tr me...
1. Monitoring planning Before creating a monitori...
Table of contents 1. Install Docker on CentOS 7.9...
<br />Original text: http://andymao.com/andy...
Copy code The code is as follows: 1. Sina Weibo &...
Linux uses files as the basis to manage the devic...
Why do we need to summarize the browser compatibi...
Table of contents Functionalcomponents Childcompo...