13.5.2.1. ANALYZE TABLE Syntax
ANALYZE [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name [, tbl_name] ...
ANALYZE TABLE analyzes and stores the key
distribution for a table. During the analysis, the table is
locked with a read lock. This statement works with
MyISAM, BDB, and
InnoDB tables. For
MyISAM tables, this statement is equivalent
to using myisamchk -a.
MySQL uses the stored key distribution to decide the order in
which tables should be joined when you perform a join on
something other than a constant.
ANALYZE TABLE returns a result set with the
following columns:
You can check the stored key distribution with the
SHOW INDEX statement. See
Section 13.5.4.15, “SHOW INDEX Syntax”.
If the table has not changed since the last ANALYZE
TABLE statement, the table is not analyzed again.
ANALYZE TABLE statements are written to the
binary log unless the optional
NO_WRITE_TO_BINLOG keyword (or its alias
LOCAL) is used. This is done so that
ANALYZE TABLE statements used on a MySQL
server acting as a replication master will be replicated by
default to the replication slave.