innodb io管理

InnoDB通过双写缓冲区确保页写入的完整性,防止操作系统或存储故障导致的撕裂页情况。对于超过半页长度的行,部分列会被存储到外部的溢出页面。InnoDB实施模糊检查点机制,分批刷新修改的数据库页面,避免在检查点过程中影响用户SQL语句的处理。崩溃恢复时,InnoDB基于日志文件中的检查点标签来应用已记录的修改。碎片管理可以通过ALTER TABLE语句进行,而TRUNCATE TABLE在innodb_file_per_table=on时用于回收磁盘空间。
摘要由CSDN通过智能技术生成

Before writing pages to a data file, InnoDB first writes them to a contiguous tablespace area called the doublewrite buffer. Only after the write and the flush to the doublewrite buffer has completed does InnoDB write the pages to their proper positions in the data file. If there is an operating system, storage subsystem, or mysqld process crash in the middle of a page write (causing a torn page condition), InnoDB can later find a good copy of the page from the doublewrite buffer during recovery.

If a row is less than half a page long, all of it is stored locally within the page. If it exceeds half a page, variable-length columns are chosen for external off-page storage until the row fits within half a page. For a column chosen for off-page storage, InnoDB stores the first 768 bytes locally in the row, and the rest externally into overflow pages. Each such column has its own list of overflow pages. The 768-byte prefix is accompanied by a 20-byte value that stores the true length of the column and points into the overflow list where the rest of the value is stored.
不知道有没有行迁移的情况
InnoDB implements a checkpoint mechanism known as fuzzy checkpointing. InnoDB flushes modified database pages from the buffer pool in small batches. There is no need to flush the buffer pool in one single batch, which would disrupt processing of user SQL statements during the checkpointing process.

During crash recovery, InnoDB looks for a checkpoint label written to the log files. It knows that all modifications to the database before the label are present in the disk image of the database. Then InnoDB scans the log files forward from the checkpoint, applying the logged modifications to the database.

mysql的检查点也比oracle要简单很多
频繁的插入,删除会导致表碎片化,要处理碎片,使用
ALTER TABLE tbl_name ENGINE=INNODB
之前在生产环境操作,以为这样执行会报语法错误,然后就执行成功了,吓了一身冷汗,不知道这个语句究竟干了什么,只能祈祷苍天了,还好原来是反碎片化的操作,以后切记在生产环境上执行的语句自己一定要知道它究竟干了什么,否则不要轻易执行。
回收磁盘空间,可以使用truncate table来回收,只在innodb_file_per_table=on的条件下才有用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值