// mysql · disk i/o

innodb_flush_neighbors

Whether flushing a page also flushes adjacent dirty pages in the same extent.

預設
0
Range
0, 1, 2
Restart needed
否
Default checked on
MySQL 8.4 LTS

其作用

Helps on spinning disks by turning random writes into sequential ones; adds pointless writes on SSDs.

預設值

0. 0 since MySQL 8.0 (1 in 5.7). Same in 8.4.

Check the current value

SHOW GLOBAL VARIABLES LIKE 'innodb_flush_neighbors';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'innodb_flush_neighbors';

Change it

SET GLOBAL innodb_flush_neighbors = 1;    -- until the next restart
SET PERSIST innodb_flush_neighbors = 1;   -- now and after restarts

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When to change it

Only turn it on for data on rotating disks.

What can go wrong

On SSDs it increases write volume.

Questions about innodb_flush_neighbors

What is the default value of innodb_flush_neighbors in MySQL?

0. 0 since MySQL 8.0 (1 in 5.7). Same in 8.4.

Does changing innodb_flush_neighbors require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When should I change innodb_flush_neighbors?

Only turn it on for data on rotating disks.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check innodb_flush_neighbors on your own server

SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.