> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/ha-and-performance/optimization-and-tuning/query-optimizations/statistics-for-optimizing-queries/innodb-persistent-statistics.md).

# InnoDB Persistent Statistics

InnoDB statistics are stored on disk and are therefore persistent.

There are a number of variables that control persistent statistics:

* [innodb\_stats\_persistent](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_stats_persistent) - when set (the default) enables InnoDB persistent statistics.
* [innodb\_stats\_auto\_recalc](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_stats_auto_recalc) - when set (the default), persistent statistics are automatically recalculated when the table changes significantly (more than 10% of the rows)
* [innodb\_stats\_persistent\_sample\_pages](/docs/server/server-usage/storage-engines/innodb/innodb-system-variables.md#innodb_stats_persistent_sample_pages) - Number of index pages sampled (default 20) when estimating cardinality and statistics for indexed columns. Increasing this value will increases index statistics accuracy, but use more I/O resources when running [ANALYZE TABLE](/docs/server/reference/sql-statements/table-statements/analyze-table.md).

These settings can be overwritten on a per-table basis by use of the [STATS\_PERSISTENT](/docs/server/server-usage/tables/create-table.md#stats_persistent), [STATS\_AUTO\_RECALC](/docs/server/server-usage/tables/create-table.md#stats_auto_recalc) and [STATS\_SAMPLE\_PAGES](/docs/server/server-usage/tables/create-table.md#stats_sample_pages) clauses in a [CREATE TABLE](/docs/server/server-usage/tables/create-table.md) or [ALTER TABLE](/docs/server/reference/sql-statements/data-definition/alter/alter-table.md) statement.

Details of the statistics are stored in two system tables in the [mysql database](/docs/server/reference/system-tables/the-mysql-database-tables.md):

* [innodb\_table\_stats](/docs/server/reference/system-tables/the-mysql-database-tables/mysql-innodb_table_stats.md)
* [innodb\_index\_stats](/docs/server/reference/system-tables/the-mysql-database-tables/mysql-innodb_index_stats.md)

The [ANALYZE TABLE](/docs/server/reference/sql-statements/table-statements/analyze-table.md) statement can be used to recalculate InnoDB statistics.

The [RENAME TABLE](/docs/server/reference/sql-statements/data-definition/rename-table.md) statement triggers a reload of the statistics.

**MariaDB starting with** [**10.11.12**](/docs/release-notes/community-server/10.11/10.11.12.md)

Prior to [MariaDB 10.11.12](/docs/release-notes/community-server/10.11/10.11.12.md), [MariaDB 11.4.6](/docs/release-notes/community-server/11.4/11.4.6.md) and [MariaDB 11.8.2](/docs/release-notes/community-server/11.8/11.8.2.md), [FLUSH TABLES](/docs/server/reference/sql-statements/administrative-sql-statements/flush-commands/flush.md) also caused InnoDB statistics to be reloaded. From [MariaDB 10.11.12](/docs/release-notes/community-server/10.11/10.11.12.md), [MariaDB 11.4.6](/docs/release-notes/community-server/11.4/11.4.6.md) and [MariaDB 11.8.2](/docs/release-notes/community-server/11.8/11.8.2.md), this is no longer the case.

## See Also

* [Index Statistics](/docs/server/ha-and-performance/optimization-and-tuning/optimization-and-indexes/index-statistics.md)
* [Engine-independent Statistics](/docs/server/ha-and-performance/optimization-and-tuning/query-optimizations/statistics-for-optimizing-queries/engine-independent-table-statistics.md)
* [Histogram-based Statistics](/docs/server/ha-and-performance/optimization-and-tuning/query-optimizations/statistics-for-optimizing-queries/histogram-based-statistics.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
