当前位置:网站首页>Mysql 45讲学习笔记(十二)MySQL会“抖”一下
Mysql 45讲学习笔记(十二)MySQL会“抖”一下
2022-07-04 06:33:00 【孔汤姆】
一.场景
一条修改SQL语句,正常时候特别快,但是偶尔特别慢,场景很难复现,持续时间短。
产生原因:
- InnoDB处理更新语句时候,只做写日志这个磁盘操作。这个日志叫做redo log(重做日志)
- 在更新内存写完redo log后,返回给客户端,本次更新成功
当内存写满,不得不同步至内存时候,就会比较缓慢
flush就是内存的数据写入磁盘中
- 脏页:当内存数据页和磁盘数据页不一致的时候
- 干净页:当内存 和磁盘上的数据页的内容一致
二.产生刷脏页的场景
- redo log满了,系统要停止所有更新操作,将checkpoint 往前推进,redo log 留出空间可以继续写。
- 系统内存不足,需要新的内存页,内存不足时候需要淘汰数据页,将脏页写到磁盘中
- MySQL 认为系统“空闲”的时
- MySQL 正常关闭时
前两种情况分析:
- redo log写满了,要刷flush脏页,这种情况InnoDB要尽量避免,系统不再接受更新,所有更新都必须堵住
- 内存不够用了,将脏页写到磁盘,这种情况是常态
InnoDB用缓存池(buffer pool)管理内存,缓存池中的内存页有三种状态:
- 未使用
- 使用了都是干净页
- 使用了但是都是脏页
InnoDB策略时尽量使用内存,对于一个长时间运行的库来说,未被使用 的页面很少
刷脏页是 常态,但是以下会明显影响性能:
- 要淘汰的脏页太多,导致查询响应时间明显变长
- 日志写满,更新全部堵住,写性能跌为0
三.InnoDB刷脏页的控制策略
InnoDB 所在主机的 IO 能力,这样 InnoDB 才能知道需要全力刷脏页的时候,可以刷多快。
innodb_io_capacity 这个参数
- 值建议设置成磁盘的IOPS
- 磁盘的IOPS可以用fio工具测试
边栏推荐
- 2022.7.2-----leetcode.871
- Can the out of sequence message complete TCP three handshakes
- SQL join, left join, right join usage
- 雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
- Appium foundation - appium installation (II)
- Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
- uniapp 自定义环境变量
- 2022.7.2-----leetcode. eight hundred and seventy-one
- Operator < <> > fool test case
- QT get random color value and set label background color code
猜你喜欢
分布式CAP理论
17-18. Dependency scope and life cycle plug-ins
Can the out of sequence message complete TCP three handshakes
【无标题】
Arcpy 利用updatelayer函数改变图层的符号系统
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
Detectron: train your own data set -- convert your own data format to coco format
C實現貪吃蛇小遊戲
随机推荐
What is Gibson's law?
What is a spotlight effect?
Bicolor case
tars源码分析之9
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai
1、 Relevant theories and tools of network security penetration testing
What is the "relative dilemma" in cognitive fallacy?
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
CORS is not intended to protect API endpoints - nikofischer
QT 获取随机颜色值设置label背景色 代码
The sorting in C language realizes the number sorting method from small to large
Lightroom import picture gray / Black rectangular multi display
Tree DP
Another company raised the price of SAIC Roewe new energy products from March 1
27-31. Dependency transitivity, principle
746. Climb stairs with minimum cost
Appium foundation - appium installation (II)
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
Common usage of time library