MYISAM table batch compress _ MySQL

Source: Internet
Author: User
MYISAM table batch compression bitsCN.com

Batch compression of MYISAM tables

These two operations need to be used with caution. before compression, you need to confirm that mysqld is disabled or that the table to be compressed does not have any other SQL operations, and the compression process will occupy cpu resources, we recommend that you do this when the server is idle.

The following is the shell process used to compress the following table of a database (it is worth noting that if the data volume is large, we recommend that you perform the operation multiple times because it takes a lot of time ):

1 #! /Bin/bash 2 data_dir = "/data/mysql/my_dbname/" 3 filelist = 'ls $ data_dir '4 echo "myisampack begin. "5 for filename in $ filelist 6 do 7 idx = 'expr match" $ filename "". *. MYI "'8 if [[$ idx> 0] 9 then10/usr/bin/myisampack $ data_dir $ filename11 fi12 done13 14 echo" MYISAMPACK End. myisamchk begin. "15 16 for filename in $ filelist17 do18 idx = 'expr match" $ filename "". *. MYI "'19 if [[$ idx> 0] 20 then21/usr/bin/myisamchk-r-o-f -- sort-index -- analyze $ data_dir $ filename22 fi23 done24 echo "myisamchk end."


BitsCN.com

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.