ANALYZE, OPTIMIZE, CHECK and REPAIR TABLE
The table maintenance statements answer as a healthy InnoDB table does; they change nothing.
These statements exist so that tools and scripts that run them get the answer they expect (D83). Raft DB keeps no table statistics and has nothing to repair, so they change nothing.
Syntax#
{ ANALYZE | OPTIMIZE | CHECK | REPAIR } [NO_WRITE_TO_BINLOG | LOCAL] TABLE
[db_name.]tbl_name [, [db_name.]tbl_name] ... [option] ...The options after the table names (QUICK, FAST, EXTENDED, USE_FRM, UPDATE HISTOGRAM ... and so on) are read up to the end of the statement and ignored.
Remarks#
- The answer has the columns
Table,Op,Msg_type,Msg_text. For a table that exists it isstatus/OK.OPTIMIZEfirst gives the note that the table does not support optimize and is recreated;REPAIRgives the note that the storage engine does not support repair. - A table that does not exist gives
Errorandstatus/Operation failed. - Each statement works on one or more tables of the current or a named database.
- The output is identical to MySQL and MariaDB (D83: both dialects).
ANALYZE,OPTIMIZE,CHECKorREPAIRwithout the wordTABLEis not accepted:ANALYZEandOPTIMIZEare refused with error 1235,CHECKandREPAIRare a syntax error.- Privileges are not checked by these statements in this version.
Examples#
Example:
ANALYZE TABLE t;
ANALYZE TABLE t, u;
ANALYZE LOCAL TABLE t;
OPTIMIZE TABLE t;
CHECK TABLE t QUICK;
REPAIR TABLE t;
CHECK TABLE c1.u, c1.nope; -- second row: Error, Operation failed