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

Source: Internet
Author: User

Production Environment MySQL table maintenance: check, optimize and analyze (I) optimize can recycle space, reduce fragments, and improve I/O currently supports the following storage engines: if InnoDB, MyASIM, and ARCHIVE are in a Replication environment, they can add NO_WRITE_TO_BINLOG (or LOCAL, Which means exactly the same), for example, optimize local table table_name. The following is a simple test: [plain] [mysql @ odd employees] $ ls-alh t. ibd-rw ---- 1 mysql dba 24 M 05-22 t. 24 M mysql> 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. after ibd optimize, there are 14 M (2) check checklists or views left. The supported table engines are: InnoDB and MyISAM. A simple test is simulated: [plain] 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: check Msg_type: Error Msg_text: Incorrect information in file :'. /employees/t. frm' *************************** 2. row *************************** Table: employees. t Op: check Msg_type: error Msg_text: sums upt 2 rows in set (0.00 sec) -- an error is reported. (3) analyze is used to collect statistics of optimizer and is related to tuning. This command is useful for tables of MyISAM, BDB, and InnoDB Storage engine. If you do not want to record binlog, you can also add the keyword local. or another [plain] mysql> analyze table t \ G; * *************************** 1. row *************************** Table: employees. t Op: analyze Msg_type: Error Msg_text: Incorrect information in file :'. /employees/t. frm' *************************** 2. row *************************** Table: employees. t Op: analyze Msg_type: error Msg_text: sums upt 2 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.