// mysql · vacuum, statistics & maintenance

innodb_purge_threads

Threads that remove delete-marked rows and old undo records.

Padrão
1 or 4
Range
1 to 32
Restart needed
Sim
Default checked on
MySQL 8.4 LTS

O que faz

Purge is InnoDB's equivalent of vacuum. If it falls behind, the history list length (SHOW ENGINE INNODB STATUS) grows and queries slow down.

Valor padrão

1 or 4. 1 when the server has 16 or fewer logical processors, otherwise 4, since MySQL 8.4 (a fixed 4 in 8.0).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'innodb_purge_threads';

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

Change it

SET PERSIST_ONLY innodb_purge_threads = 4;
-- then restart mysqld (or set it under [mysqld] in my.cnf)

Restart required: the variable is read-only at runtime (SET GLOBAL fails with error 1238). Stage it with SET PERSIST_ONLY or under [mysqld] in my.cnf.

When to change it

When history list length keeps growing under heavy DML.

What can go wrong

Low.

Questions about innodb_purge_threads

What is the default value of innodb_purge_threads in MySQL?

1 or 4. 1 when the server has 16 or fewer logical processors, otherwise 4, since MySQL 8.4 (a fixed 4 in 8.0).

Does changing innodb_purge_threads require a restart?

Yes. Restart required: the variable is read-only at runtime (SET GLOBAL fails with error 1238). Stage it with SET PERSIST_ONLY or under [mysqld] in my.cnf.

When should I change innodb_purge_threads?

When history list length keeps growing under heavy DML.

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

// one client for every engine

Check innodb_purge_threads 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.