ANALYZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE tbl_name [, tbl_name] ...
ANALYZE TABLE works with
MyISAM tables. It does not work with views.
ANALYZE TABLE is supported for
partitioned tables, and you can use
ALTER TABLE ...
ANALYZE PARTITION to analyze one or more partitions;
for more information, see Section 13.1.8, “ALTER TABLE Syntax”, and
Section 22.3.4, “Maintenance of Partitions”.
During the analysis, the table is locked with a read lock for
By default, the server writes
TABLE statements to the binary log so that they
replicate to replication slaves. To suppress logging, specify
NO_WRITE_TO_BINLOG keyword or
ANALYZE TABLE returns a result
set with the columns shown in the following table.
|The table name|
|An informational message|
If the table has not changed since the last key distribution analysis, the table is not analyzed again.
MySQL uses the stored key distribution to decide the table join order for joins on something other than a constant. In addition, key distributions can be used when deciding which indexes to use for a specific table within a query.
For more information on how key distribution analysis works
Section 188.8.131.52, “Configuring Persistent Optimizer Statistics Parameters” and
Section 184.108.40.206, “Estimating ANALYZE TABLE Complexity for InnoDB Tables”. Also see
Section 220.127.116.11, “Limits on InnoDB Tables”. In particular, if the
system variable is enabled, you must run
ANALYZE TABLE after loading
substantial data into an
InnoDB table, or
creating a new index for one.
To check the stored key distribution cardinality, use the
SHOW INDEX statement or the
table. See Section 18.104.22.168, “SHOW INDEX Syntax”, and
Section 24.23, “The INFORMATION_SCHEMA STATISTICS Table”.