Mysql 5.6 partition Maintenance

Source: Internet
Author: User

Some maintenance tasks for mysql 5.6 partition maintenance tables and partitions are applicable to the use of SQL statements on mysql partition tables. To maintain a partition TABLE, you can use statements that support partition tables: check table, optimize table, analyze table, and repair table you can use some extension of alter table to execute one or more partitions of this type. 1. Re-partition: This is the same as deleting all records saved in the partition and then re-inserting them. It can be used to organize partition fragments. For example, alter table t1 rebuild partition p0, p1; 2. optimized partition: if a large number of rows are deleted from the partition, or a row with a variable length (that is, a VARCHAR, BLOB, or TEXT column) is modified a lot, you can use "alter table... optimize partition "to reclaim unused space and sort the shards of PARTITION data files. For example: alter table t1 optimize partition p0, p1; using "optimize partition" on a given partition table is equivalent to running check partition, analyze partition, and repair partition on that PARTITION. 3. Analyze partitions: Read and save the partition key distribution. For example, alter table t1 analyze partition p3; 4. Repair partitions: repair damaged partitions. For example, alter table t1 repair partition p0, p1; 5. CHECK partitions: CHECK partitions in almost the same way as CHECK tables for non-PARTITION tables. For example, alter table trb3 check partition p1. This Command tells you whether the data or index in PARTITION p1 of TABLE t1 has been damaged. If this happens, use "alter table... repair partition" to fix the PARTITION. Each statement in the list also supports replacing the partition name in the list with the keyword "ALL. For example, alter table trb3 check partition all; using mysqlcheck and myisamchk does not support PARTITION tables. In mysql 5.6, you can use alter table... truncate partition to TRUNCATE partitions. This statement can be used to delete all rows in one or more partitions. It is similar to the operation of truncate table to delete all rows from the TABLE. Alter table... truncate partition all truncates ALL partitions in the TABLE.

Related Article

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.