Mysql – Control InnoDB buffer pool allocation in MySQL (5.7+)

indexinnodbMySQL

I have some large tables which causes to fill the InnoDB buffer pool and removing other data.

Is there any way how can I control the InnoDB buffer allocation in one shared database?

Like:
a) Limit the buffer size for one table
b) Limit the buffer size for data (so indexes will remain cached)
c) Allocate a buffer exclusively for one particular table or even for one particular table index (or for all indexes in one table)

Best Answer

I am sorry to bring this up but only MyISAM does what you asking for when it comes to caching indexes for a specific table. I have written about this before. At this time, using MyISAM is like MySQL sacrilege, but if you are that desparate to cache indexes independently and your tables are read only, you can try converting them to MyISAM and setting up dedicated keycaches. CAVEAT : YOU DIDN'T HEAR THIS FROM ME !!

BACK TO REALITY...

Perhaps you should consider taking snapshots of the Buffer Pool.

Whenever you get the InnoDB Buffer Pool into the state you want, run this

SET GLOBAL innodb_buffer_pool_dump_now = 1;

This will generate a file called ib_buffer_pool (usually located in datadir), containing a map of all tablespace_ids that are in the Buffer Pool at that moment. You could copy this file to some folder and retrieve it later.

You could reload ib_buffer_pool by running

SET GLOBAL innodb_buffer_pool_load_now = 1;

This will copy all .ibd pages (data and indexes) back into the InnoDB Buffer Pool.

You should consider taking a snapshot of the buffer pool before running a backup and reloading the buffer pool afterwards.

For more information, please read the MySQL Documentation on innodb_buffer_pool_dump_now and innodb_buffer_pool_load_now.