A number of table and partition maintenance tasks can be carried out using SQL statements intended for such purposes on partitioned tables in MySQL 5.6.
Table maintenance of partitioned tables can be accomplished
using the statements CHECK TABLE,
OPTIMIZE TABLE,
ANALYZE TABLE, and
REPAIR TABLE, which are supported
for partitioned tables.
You can use a number of extensions to
ALTER
TABLE for performing operations of this type on one or
more partitions directly, as described in the following list:
Rebuilding partitions. Rebuilds the partition; this has the same effect as dropping all records stored in the partition, then reinserting them. This can be useful for purposes of defragmentation.
Example:
ALTER TABLE t1 REBUILD PARTITION p0, p1;
Optimizing partitions.
If you have deleted a large number of rows from a
partition or if you have made many changes to a
partitioned table with variable-length rows (that is,
having VARCHAR,
BLOB, or TEXT
columns), you can use ALTER TABLE ... OPTIMIZE
PARTITION to reclaim any unused space and to
defragment the partition data file.
Example:
ALTER TABLE t1 OPTIMIZE PARTITION p0, p1;
Using OPTIMIZE PARTITION on a given
partition is equivalent to running CHECK
PARTITION, ANALYZE PARTITION,
and REPAIR PARTITION on that partition.
Analyzing partitions. This reads and stores the key distributions for partitions.
Example:
ALTER TABLE t1 ANALYZE PARTITION p3;
Repairing partitions. This repairs corrupted partitions.
Example:
ALTER TABLE t1 REPAIR PARTITION p0,p1;
Checking partitions.
You can check partitions for errors in much the same way
that you can use CHECK TABLE with
nonpartitioned tables.
Example:
ALTER TABLE trb3 CHECK PARTITION p1;
This command will tell you if the data or indexes in
partition p1 of table
t1 are corrupted. If this is the case,
use ALTER TABLE ... REPAIR PARTITION to
repair the partition.
Each of the statements in the list just shown also supports the
keyword ALL in place of the list of partition
names. Using ALL causes the statement to act
on all partitions in the table.
The use of mysqlcheck and myisamchk is not supported with partitioned tables.
In MySQL 5.6, you can also truncate partitions
using ALTER TABLE
... TRUNCATE PARTITION. This statement can be used to
delete all rows from one or more partitions in much the same way
that TRUNCATE TABLE deletes all
rows from a table.
ALTER TABLE ...
TRUNCATE PARTITION ALL truncates all partitions in the
table.

User Comments
There is a bug with the ARCHIVE storage engine preventing partition repairs:
e.g.
mysql> alter table table_name repair partition p7\G
*************************** 1. row ***************************
Table: schema.table_name
Op: repair
Msg_type: error
Msg_text: Partition p7 returned error
*************************** 2. row ***************************
Table: schema.table_name
Op: repair
Msg_type: error
Msg_text: Corrupt
This is a known bug so this output is expected behavior.
This manual page misses the fact that for InnoDB partitioned tables, OPTIMIZE TABLE will not optimize a single partition but a whole table instead. This is what I get when I try "ALTER TABLE mytable OPTIMIZE PARTITION p1;" (MySQL 5.6.10):
"Table does not support optimize on partitions. All partitions will be rebuilt and analyzed."
There is bug report here: http://bugs.mysql.com/bug.php?id=42822
Instead, that manual page contains information about this fact: https://dev.mysql.com/doc/refman/5.6/en/alter-table-partition-operations.html
Still a warning should exist also on this page.
The workaround to perform optimization on a single partition of InnoDB table is:
ALTER TABLE ... REBUILD PARTITION
ALTER TABLE ... ANALYZE PARTITION
Add your own comment.