Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

17.3.3. Maintenance of Partitions

A number of partitioning maintenance tasks can be carried out in MySQL 5.1. MySQL does not support the commands CHECK TABLE, OPTIMIZE TABLE, ANALYZE TABLE, or REPAIR TABLE for partitioned tables. Instead, you can use a number of extensions to ALTER TABLE which were implemented in MySQL 5.1.5. These can be used 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 non-partitioned 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.

You can also use the mysqlcheck or myisamchk utility to accomplish these tasks, operating on the separate .MYI files generated by partitioning a table. See Section 8.9, “mysqlcheck — A Table Maintenance and Repair Program”.


 
 
  Published under the terms of the GNU General Public License Design by Interspire