[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ANALYZE TABLE
Syntax
ANALYZE [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name[,tbl_name...] |
Analyze and store the key distribution for the table. During the
analysis, the table is locked with a read lock. This works on
MyISAM
and BDB
tables.
This is equivalent to running myisamchk -a
on the table.
MySQL uses the stored key distribution to decide in which order tables should be joined when you perform a join on something other than a constant.
The command returns a table with the following columns:
Column | Value |
Table | Table name |
Op | Always analyze |
Msg_type | One of status , error , info , or warning |
Msg_text | The message |
You can check the stored key distribution with the SHOW INDEX
command.
See section 13.5.3.1 Retrieving Information about Database, Tables, Columns, and Indexes.
If the table hasn't changed since the last ANALYZE TABLE
command,
the table will not be analyzed again.
Before MySQL 4.1.1, ANALYZE
commands are not written
to the binary log. Since MySQL 4.1.1 they are written to the binary
log unless the optional NO_WRITE_TO_BINLOG
keyword
(or its alias LOCAL
) was used.