An InnoDB table statistics is used for JOIN optimizations and
helping the MySQL optimizer choose the appropriate index for a
query. If a table’s statistics or index cardinality becomes
outdated, you might see queries which previously performed well
suddenly show up on slow query log until InnoDB again updates the
statistics. But when does InnoDB perform the updates aside from
the first opening of the table or manually running ANALYZE
TABLE on it? The 2 instances below are documented from the
MySQL and InnoDB plugin’s manual:
- Metadata commands like
SHOW INDEX,SHOW TABLE STATUSandSHOW [FULL] TABLES(or their corresponding queries from INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.STATISTICS) - When 1 / 16th of the table or 2Billion rows has been
modified, whichever comes
first.
./row/row0mysql.c:row_update_statistics_if_needed
…
[Read more]