Innodb特性之Read-Ahead(Buffer Pool Prefetching)

来源:这里教程网 时间:2026-03-01 15:23:59 作者:

Read-Ahead官方说明: https://dev.mysql.com/doc/refman/5.7/en/innodb-performance-read_ahead.html

设计目的:Read-Ahead用于异步预取buffer pool中的多个page的一个预测行为。InnoDB使用两种提前预读Read-Ahead算法来提高I/O性能。 Linear read-ahead:线性预读如果一个extent中的被顺序读取的page超过或者等于   innodb_read_ahead_threshold  参数变量时,Innodb将会异步的将下一个extent读取到buffer pool中,innodb_read_ahead_threshold可以设置为0-64的任何值(注:innodb中每个extent就只有64个page),默认为56。值越大,访问模式检查就越严格。Mark:官网说会预读取下一个extent,但当前extent剩下没有取完的page也会一起读取嘛? 还不没找到说明 Random read-ahead:随机预读如果当同一个extent中连续的13个page在buffer pool中发现时,Innodb会将该extent中的剩余page读到buffer pool中。控制参数  innodb_random_read_ahead  默认没有开启。 评估预读算法的有效性The  SHOW ENGINE INNODB STATUS command displays statistics to help you evaluate the effectiveness of the read-ahead algorithm. Statistics include counter information for the following global status variables:

  • Innodb_buffer_pool_read_ahead 通过预读读入buffer pool中数据page数

  • Innodb_buffer_pool_read_ahead_evicted 通过预读没有被访问就被驱逐的page

  • Innodb_buffer_pool_read_ahead_rnd 通过随机预读的次数

  • 相关推荐