Skip to content

2 Steps to Compress MySQL Tables

  • by
Two steps to make your table compressed.
  1. Set the server INNODB_FILE_FORMAT to Barracuda.
  2. mysql> SET GLOBAL INNODB_FILE_FORMAT=Barracuda;
  3. Alter table to compressed with 8KB key block size.
  4. mysql> ALTER TABLE `compressed table` ROW_FORMAT=COMPRESSED, KEY_BLOCK_SIZE=8;
    Actually, if your key block is 8KB, the default format is compressed for this size, you don't have to set ROW_FORMAT literally. So we can also use the following short statement to make it compressed.
    mysql> ALTER TABLE `compressed table` KEY_BLOCK_SIZE=8;
As you can see, I used pairs of backquote (`) to escape any possible special characters in table name in order to keep the statement safe.

Leave a Reply

Your email address will not be published.