The InnoDB buffer pool is the memory MySQL uses to cache table data and indexes. It is the single most important setting for WordPress database speed.
How big should innodb_buffer_pool_size be? #
On a dedicated database server, use roughly 60 to 70 percent of total RAM. On a server that also runs PHP and NGINX, start at 25 to 40 percent. The goal is that your working set of hot tables fits in memory, while leaving enough RAM for the operating system and PHP workers.
Check your current hit ratio #
SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool_read%';
-- hit ratio = 1 - (Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests)
A ratio above 99 percent is healthy. Below 95 percent usually means the pool is too small for your data.
Apply the change #
# /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
# then restart MySQL
sudo systemctl restart mysql
Restarting MySQL briefly interrupts your site. Schedule the change for a quiet period and take a backup first.
Verify after restart #
SHOW VARIABLES LIKE 'innodb_buffer_pool_size';