The persistent optimizer statistics feature improves plan stability by storing statistics to disk and making them persistent across server restarts so that the optimizer is more likely to make consistent choices each time for a given query.
Optimizer statistics are persisted to disk when innodb_stats_persistent=ON
or when individual tables are defined with STATS_PERSISTENT=1
. innodb_stats_persistent
is enabled by default.
Formerly, optimizer statistics were cleared when restarting the server and after some other types of operations, and recomputed on the next table access. Consequently, different estimates could be produced when recalculating statistics leading to different choices in query execution plans and variation in query performance.
Persistent statistics are stored in the mysql.innodb_table_stats
and mysql.innodb_index_stats
tables. See Section 15.8.10.1.5, “InnoDB Persistent Statistics Tables”.
If you prefer not to persist optimizer statistics to disk, see Section 15.8.10.2, “Configuring Non-Persistent Optimizer Statistics Parameters”