• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

主键乱序插入对Innodb性能的影响_MySQL

mysql 搞代码 4年前 (2022-01-09) 19次浏览 已收录 0个评论
文章目录[隐藏]

gaodaima.com

在平时的mysql文档学习中我们经常会看到这么一句话:

MySQL tries to leave space so that future inserts do not incur un-necessary page splits (and thus higher IO cost). In an “ideal” world, MySQL tries to keep the index pages at 15/16-th full, but depending on insert order, this fill factor can be as low as 1/2

大致含义就是当我们按照索引顺序插入时,page的填充率能达到15/16 , 而乱序插入时只能到略大于 1/2 的填充率。

那么这个说法是否正确呢?是否有相应的理论依据呢?

本文将通过一些测试来验证这个观点的真伪。

测试数据准备

简介: 顺序数据通过sysbench –oltp-table-size = 8000000 生成,然后通过order by rand() 生成乱序数据。

mysql> desc sbtest;+-------+------------------+------+-----+---------+----------------+| Field | Type             | Null | Key | Default | Extra          |+-------+------------------+------+-----+---------+----------------+| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment || k     | int(10) unsigned | NO   | MUL | 0       |                || c     | char(120)        | NO   |     |         |                || pad   | char(60)         | NO   |     |         |                |+-------+------------------+------+-----+---------+-------<strong style="color:transparent">来源gaodai#ma#com搞@代~码$网</strong>---------+

gaodaima.com


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:主键乱序插入对Innodb性能的影响_MySQL

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址