If I have some (hot) pages in the InnoDB buffer, and I perform a query which reads an amount of data larger than the buffer itself, will the hot pages be necessarily evicted?
InnoDB Buffer Pool – Are Pages Evicted When Exceeding Buffer Size?
buffer-pooldata-pagesdatabase-internalsinnodbMySQL
Related Question
- Mysql – Does innodb_data_reads include reads from the buffer pool
- Mysql – What are the different ways to Warmup InnoDB Buffer Pool in MySQL 5.6
- Mysql – reduce number of innodb pages read by a query
- Mysql – Would the MySQL database benefit from increasing the InnoDB buffer pool size
- MySQL InnoDB Files – Structure and Page Composition
- Mysql – What happens when MySQL/InnoDB buffer pool size is small and a large transaction is run causing the buffer pool overflow
- Innodb – Partitioning and the InnoDB Buffer Pool
Best Answer
According to MySQL 5.7 Reference Manual - The InnoDB Buffer Pool
(emphasis mine)
I think this is the answer you're looking for. Not all pages are evicted, they're evicted one at at a time, and only of the old ones will be evicted each time. Obviously, if queries need twice (or more) of the available pool, eventually all pages might be evicted, depending on how frequently they're used.
I'd say that all pages near the root of B+trees (used for indices and the way tables are clustered) will be used more frequently than the rest, and so, they're unlikely to ever be evicted. However, some situations where there are just lots of full table scans, that (probably) pass through pages just once, might end up having all your hot pages overwhelmed and evicted. I don't think this is likely, but theoretically possible.