Mysql InnoDB的内存管理--LRU链表

Mysql Innodb Buffer Pool的LRU设计思路:


1.InnoDB把整个LRU链表按照5:3的比例(由参数innodb_old_blocks_pct控制)分为old区域和new区域,其中LRU_OLD占3/8,LRU_NEW占5/8
2.如果要访问一个不在当前链表里的数据页时,新的数据页会插入到LRU_OLD的队首,如果链表满的话,会从LRU_OLD的队尾相应的淘汰掉一个数据页
3.处于LRU_OLD里的数据页,每次访问时都需要判断一下:
    1)如果该数据页在LRU链表中存在时间超过1s,就将其移动到链表头部(这里面说的链表指的是整个LRU链表)
    2)如果该数据页在LRU链表中存在的时间短于1s,其位置不变
    3)1s这个时间是由参数innodb_old_blocks_time控制的
    
innodb_old_blocks_time:
Dynamic Yes、DEFAULT VALUE 1000、Scope Global、Minimum Value 0、Maximum Value 2**32-1
Non-zero values protect against the buffer pool being filled by data that is referenced only for a brief period, such as during a full table scan. Increasing this value offers more protection against full table scans interfering with data cached in the buffer pool.
Specifies how long in milliseconds a block inserted into the old sublist must stay there after its first access before it can be moved to the new sublist.

innodb_old_blocks_pct:
Dynamic Yes、DEFAULT VALUE 37、Scope Global、Minimum Value 5、Maximum Value 95
Specifies the approximate percentage of the InnoDB buffer pool used for the old block sublist. The range of values is 5 to 95. The default value is 37 (that is, 3/8 of the pool). Often used in combination with innodb_old_blocks_time.

这种设计思路主要是为了防止那种一次性的大的查询(比如全表扫描)把内存的LRU链表全部更新掉,进而影响Buffer Pool的内存命中率

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值