Documentation Home
MySQL 9.2 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 259.7Kb
Man Pages (Zip) - 366.9Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.2 Reference Manual  / ...  / The InnoDB Storage Engine  / InnoDB Configuration  /  Configuring Optimizer Statistics for InnoDB

17.8.10 Configuring Optimizer Statistics for InnoDB

This section describes how to configure persistent and non-persistent optimizer statistics forInnoDB tables.

Persistent optimizer statistics are persisted across server restarts, allowing for greaterplan stability and more consistent query performance. Persistent optimizer statistics also provide control and flexibility with these additional benefits:

  • You can use theinnodb_stats_auto_recalc configuration option to control whether statistics are updated automatically after substantial changes to a table.

  • You can use theSTATS_PERSISTENT,STATS_AUTO_RECALC, andSTATS_SAMPLE_PAGES clauses withCREATE TABLE andALTER TABLE statements to configure optimizer statistics for individual tables.

  • You can query optimizer statistics data in themysql.innodb_table_stats andmysql.innodb_index_stats tables.

  • You can view thelast_update column of themysql.innodb_table_stats andmysql.innodb_index_stats tables to see when statistics were last updated.

  • You can manually modify themysql.innodb_table_stats andmysql.innodb_index_stats tables to force a specific query optimization plan or to test alternative plans without modifying the database.

The persistent optimizer statistics feature is enabled by default (innodb_stats_persistent=ON).

Non-persistent optimizer statistics are cleared on each server restart and after some other operations, and recomputed on the next table access. As a result, different estimates could be produced when recomputing statistics, leading to different choices in execution plans and variations in query performance.

This section also provides information about estimatingANALYZE TABLE complexity, which may be useful when attempting to achieve a balance between accurate statistics andANALYZE TABLE execution time.