MySQL table maintenance in the production environment: Check, optimize, and analyze

Source: Internet
Author: User
(I) Optimize

Optimize can recycle space, reduce fragments, and increase I/O
Currently, the following storage engines are supported: InnoDB, myasim, and archive.

If it is a replication environment, add no_write_to_binlog (or local, the meaning is exactly the same), for example:
Optimize local table table_name;

The following is a simple test:

[MySQL @ odd employees] $ LS-alh t. IBD-RW ---- 1 MySQL DBA 24 m 05-22 t. 24 mmysql> optimize table t before IBD does not optimize; + ------------- + ---------- + upper + | table | op | msg_type | msg_text | + --------------- + ---------- + lower + | employees. T | optimize | note | table does not support optimize, doing recreate + analyze instead | employees. T | optimize | status | OK | + --------------- + ---------- + --------------------------------------------------------------- + 2 rows in SET (3.82 Sec) -- no error is reported for InnoDB tables and the above content. MySQL will help you map to: alter table table_name engine = 'innodb '; -- MyISAM does not have this situation [MySQL @ odd employees] $ LS-alh t. IBD-RW ---- 1 MySQL DBA 14 m 05-22 t. 14 Mb after IBD optimize

(Ii) Check

Check table or view errors
Table engines supported: InnoDB and MyISAM

A test is simulated below:

Mysql> check table t; + ------------- + ------- + ---------- + | table | op | msg_type | msg_text | + ------------- + ------- + ---------- + | employees. T | check | status | OK | + ------------- + ------- + ---------- + 1 row in SET (0.63 Sec) -- this is the case if there is no error -- use Vim to open T. FRM arbitrarily edits two mysql> check table t \ G; * *************************** 1. row *************************** table: employees. T op: checkmsg_type: errormsg_text: incorrect information in file :'. /employees/t. frm' *************************** 2. row *************************** table: employees. T op: checkmsg_type: errormsg_text: corrupt2 rows in SET (0.00 Sec) -- error reported


(3) analyze

Used to collect optimizer statistics, and tuning-related,
This command is useful for tables of the MyISAM, bdb, and InnoDB Storage engines.
If you do not want to record BINLOG, you can add the keyword local or another

mysql> analyze table t\G;*************************** 1. row ***************************   Table: employees.t      Op: analyzeMsg_type: ErrorMsg_text: Incorrect information in file: './employees/t.frm'*************************** 2. row ***************************   Table: employees.t      Op: analyzeMsg_type: errorMsg_text: Corrupt2 rows in set (0.00 sec)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.