1. Configuring the Merge Threshold for Index Pages
You can configure the MERGE_THRESHOLD value for index pages. If the “page-full” percentage for an index page falls below the MERGE_THRESHOLD value when a row is deleted or when a row is shortened by an UPDATE operation, InnoDB attempts to merge the index page with a neighboring index page. The default MERGE_THRESHOLD value is 50【默认值是50】, which is the previously hardcoded value. The minimum MERGE_THRESHOLD value is 1 and the maximum value is 50.
When the “page-full” percentage for an index page falls below 50%, which is the default MERGE_THRESHOLD setting, InnoDB attempts to merge the index page with a neighboring page. If both pages are close to 50% full, a page split can occur soon after the pages are merged. If this merge-split behavior occurs frequently, it can have an adverse affect on performance.【频繁反复,频繁的合合分分,太内耗了,对性能也会产生很大的损失】 To avoid frequent merge-splits, you can lower the MERGE_THRESHOLD value so that InnoDB attempts page merges at a lower “page-full” percentage. Merging pages at a lower page-full percentage leaves more room in index pages and helps reduce merge-split behavior.【防止的措施,就是降低触发合并的条件,思路就是减少合并】
The MERGE_THRESHOLD for index pages can be defined for a table or for individual indexes. A MERGE_THRESHOLD value defined for an individual index takes priority over a MERGE_THRESHOLD value defined for the table. If undefined, the MERGE_THRESHOLD value defaults to 50.–【可以针对表级进行设置】
1.1 Setting MERGE_THRESHOLD for a Table–针对表
针对表,进行设置,可以通过以下方式
创建表时
CREATE TABLE t1 ( id INT, KEY id_index (id) ) COMMENT='MERGE_THRESHOLD=45';
也可以,通过修改表的方式
CREATE TABLE t1 ( id INT, KEY id_index (id) ); ALTER TABLE t1 COMMENT='MERGE_THRESHOLD=40';
1.2 Setting MERGE_THRESHOLD for Individual Indexes –针对具体的索引
To set the MERGE_THRESHOLD value for an individual index, you can use the index_option COMMENT clause with CREATE TABLE, ALTER TABLE, or CREATE INDEX, as shown in the following examples:
创建表时,就指定了index属性
CREATE TABLE t1 ( id INT, KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40' );
修改表
CREATE TABLE t1 ( id INT, KEY id_index (id) ); ALTER TABLE t1 DROP KEY id_index; ALTER TABLE t1 ADD KEY id_index (id) COMMENT 'MERGE_THRESHOLD=40';
甚至可以是修改 索引
CREATE TABLE t1 (id INT); CREATE INDEX id_index ON t1 (id) COMMENT 'MERGE_THRESHOLD=40';
注意:You cannot modify the MERGE_THRESHOLD value at the index level for GEN_CLUST_INDEX, which is the clustered index created by InnoDB when an InnoDB table is created without a primary key or unique key index. You can only modify the MERGE_THRESHOLD value for GEN_CLUST_INDEX by setting MERGE_THRESHOLD for the table.
1.3 Querying the MERGE_THRESHOLD Value for an Index –查询
The current MERGE_THRESHOLD value for an index can be obtained by querying the INNODB_INDEXES table.
SELECT * FROM INFORMATION_SCHEMA.INNODB_INDEXES WHERE NAME='id_index' \G
You can use SHOW CREATE TABLE【也可以通过这个查看】 to view the MERGE_THRESHOLD value for a table, if explicitly defined using the table_option COMMENT clause.
注意: A MERGE_THRESHOLD value defined at the index level takes priority over a MERGE_THRESHOLD value defined for the table. If undefined, MERGE_THRESHOLD defaults to 50% (MERGE_THRESHOLD=50, which is the previously hardcoded value.【表中index有定义;同时表也可以有定义】
Likewise, you can use SHOW INDEX to view the MERGE_THRESHOLD value for an index, if explicitly defined using the index_option COMMENT clause.–
【也可以查看指定的Index的定义值】
1.4 Measuring the Effect of MERGE_THRESHOLD Settings
The INNODB_METRICS table provides two counters that can be used to measure the effect of a MERGE_THRESHOLD setting on index page merges.–【通过这个系统表去查看】
SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME like '%index_page_merge%';
When lowering the MERGE_THRESHOLD value, the objectives are:
• A smaller number of page merge attempts and successful page merges
• A similar number of page merge attempts and successful page merges
A MERGE_THRESHOLD setting that is too small could result in large data files due to an excessive amount of empty page space.
2. Enabling Automatic Configuration for a Dedicated MySQL Server
When innodb_dedicated_server is enabled, InnoDB automatically configures the following variables:
• innodb_buffer_pool_size
• innodb_redo_log_capacity or, prior to MySQL 8.0.30, innodb_log_file_size and innodb_log_files_in_group.
• innodb_flush_method
Only consider enabling innodb_dedicated_server if the MySQL instance resides【rɪˈzaɪdz 居住在;定居于】 on a dedicated server where it can use all available system resources. For example, consider enabling innodb_dedicated_server if you run MySQL Server in a Docker container or dedicated VM that only runs MySQL. Enabling innodb_dedicated_server is not recommended if the MySQL instance shares system resources with other applications.
If an automatically configured option is configured explicitly in an option file or elsewhere, the explicitly specified setting is used, and a startup warning similar to this is printed to stderr:
[Warning] [000000] InnoDB: Option innodb_dedicated_server is ignored for innodb_buffer_pool_size because innodb_buffer_pool_size=134217728 is specified explicitly.
Explicit configuration of one option does not prevent the automatic configuration of other options.
If innodb_dedicated_server is enabled and innodb_buffer_pool_size is configured explicitly, variables configured based on buffer pool size use the buffer pool size value calculated according to the amount of memory detected on the server rather than the explicitly defined buffer pool size value.
Automatically configured settings are evaluated and reconfigured if necessary each time the MySQL server is started.
—https://dev.mysql.com/doc/refman/8.0/en/index-page-merge-threshold.html
—https://dev.mysql.com/doc/refman/8.0/en/innodb-dedicated-server.html
1.本站内容仅供参考,不作为任何法律依据。用户在使用本站内容时,应自行判断其真实性、准确性和完整性,并承担相应风险。
2.本站部分内容来源于互联网,仅用于交流学习研究知识,若侵犯了您的合法权益,请及时邮件或站内私信与本站联系,我们将尽快予以处理。
3.本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
4.根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。
5.本站是非经营性个人站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途
暂无评论内容