MYSQL的InnoDB Buffer Pool内部机制

        1. 基本结构:INNODB用least recently used (LRU) 算法来管理他的buffer_pool。 buffer_pool在内部被分隔为两个list. a young list 和 a old list.

        Young list 存储那些高频使用的缓存数据(默认占整个BUFFER的5/8)

        Old list 存储那些低频使用的数据(默认占整个BUFFER的3/8)


     2.使用机制:当一个新块数据被从磁盘缓存到buffer当中,它默认被放在Old list的头部,即midpoint。Old list内的任何一个块数据被再次访问,innodb都会把它加入到Young list的头部。但如果块数据是被read-ahead机制访问,它不会马上被加载到Young list。 当长期不使用的数据块被挤到了Old list的尾巴,就会被系统回收。


     3. 配置方式:

                    innodb_old_blocks_pct:设定 Young list 和 Old list 的比例。(default value is 37 (that is, 3/8 of the pool).

                    innodb_old_blocks_time:设置Old list内的数据块被访问后到加入 Young list的延迟时间。默认是0,即马上加入Young list。当临时使用一些dump或全表扫描时,可是使用此参数避免大量的数据块被回收。

        

        4. 监控:show engine innodb status的BUFFER POOL AND MEMORY部分包含里Old/Young list的使用情况

                    Old database pages:包含在Old list内的数据页数

                    Pages made young:The number of old pages that were moved to the head of the buffer pool (the new sublist)

                    not young:he number of pages that have remained in the old sublist without being made new

                    youngs/s:导致数据块加入Young list的访问进程数(注:这里是进程数,而不是数据块数量)

                    non-youngs/s:没有导致……

                    young-making rate:Hits that cause blocks to move to the head of the buffer pool

                    not: Hits that do not cause blocks to move to the head of the buffer pool (due to the delay not being met)

                     (young-making rate and not rate will not normally add up to the overall buffer pool hit rate)


        5. 新版的5.5的多pool 机制:设置innodb_buffer_pool_instances大于1,可使用多个pool, 使得访问竞争被分散。每块pool的大小等于innodb_buffer_pool_size/innodb_buffer_pool_instances,。(注意:每块至少不能不要小于1G。)


你可能感兴趣的:(InnoDB,buffer,pool)