This blog post is inspired by Jesper's recent blog post on how the automatic update of InnoDB persistent statistics may never trigger if servers are restarted frequently. However, the matter is even worse! In this blog post I will show that even when the automatic recalculation is performed, there are no guarantees as to when the server will see the changes.
Myths about persistent statistics
I must admit that I, for a long time, believed in the myths I was told about when updates to InnoDB's index statistics become visible to the query optimizer. There were basically two variants:
- The updated statistics will only be visible to new connections (i.e., sessions that are started after the statistics was updated)
- When a new connection accesses the table, the updated statistics …