snippetsqlMinor
How can I find out the last time a MySQL table was analyzed?
Viewed 0 times
canthelasthowanalyzedtimemysqlfindwasout
Problem
I'm interested in this for InnoDB mostly, but also for MyISAM.
I looked around in information_schema and did not see this data anywhere.
I'm using MySQL 5.5.16.
I looked around in information_schema and did not see this data anywhere.
I'm using MySQL 5.5.16.
Solution
There is no immediate control data to tell you that, but there are a few mechanisms you can setup.
MECHANISM #1
If you have binary logging enabled, simply do a
MECHANISM #2
If you have the general log enabled, simply do a
MECHANISM #3
You should schedule a cronjob that runs
MECHANISM #4
Try setting innodb_stats_on_metadata to have a measure of predictability as to when an InnoDB table needs
When are InnoDB table index statistics updated? )
CAVEAT
In the past, I have often stated that running
Hopefully,
MECHANISM #1
If you have binary logging enabled, simply do a
grep -i "analyze table" against all the binary logs using the output from mysqlbinlog.MECHANISM #2
If you have the general log enabled, simply do a
grep -i "analyze table" against the general log file and locate the timestamp just about the command.MECHANISM #3
You should schedule a cronjob that runs
ANALYZE TABLE against all tables that have high-write, high-update, high-delete volume. That way, there is no guess work.MECHANISM #4
Try setting innodb_stats_on_metadata to have a measure of predictability as to when an InnoDB table needs
ANALYZE TABLE. (See my Mar 26, 2012 post :When are InnoDB table index statistics updated? )
CAVEAT
In the past, I have often stated that running
ANALYZE TABLE table against InnoDB is useless.Jun 21, 2011: From where does the MySQL Query Optimizer read index statistics?
Aug 04, 2011: Optimizing InnoDB default settings
Oct 16, 2011: Suddenly have to rebuild indexes to prevent site from going down
Hopefully,
MECHANISM #4 is probably what you need.Context
StackExchange Database Administrators Q#31449, answer score: 3
Revisions (0)
No revisions yet.