patternsqlMinor
Table compression in InnoDB?
Viewed 0 times
compressiontableinnodb
Problem
I have read that table index compression happens just in MyISAM, but I came across
an article in dev.mysql that said: InnoDB supports table and index compression!
So now what is the pros of MyISAM?
Is there any reason left to use MyISAM? (except full-text search)
an article in dev.mysql that said: InnoDB supports table and index compression!
So now what is the pros of MyISAM?
Is there any reason left to use MyISAM? (except full-text search)
Solution
Recovering Disk Space
As far as recovering InnoDB diskspace goes, you only have to migrate data out of ibdata1 and import it back one time if you enable innodb_file_per_table.
Once you do that, any InnoDB table that gets bloated can be shrunk. For example, if you have an InnoDB called
or
Restoring Databases
@Craig is totally right on MyISAM.
As for InnoDB, restoring tables individually can be a nightmare. This is the case because tables are either inside ibdata1 (innodb_file_per_table=0) or outside (innodb_file_per_table=1).
As far as recovering InnoDB diskspace goes, you only have to migrate data out of ibdata1 and import it back one time if you enable innodb_file_per_table.
Once you do that, any InnoDB table that gets bloated can be shrunk. For example, if you have an InnoDB called
mydb.mytable, you can shrink it with:ALTER TABLE mydb.mytable ENGINE=InnoDB;or
OPTIMIZE TABLE mydb.mytable;Restoring Databases
@Craig is totally right on MyISAM.
As for InnoDB, restoring tables individually can be a nightmare. This is the case because tables are either inside ibdata1 (innodb_file_per_table=0) or outside (innodb_file_per_table=1).
- For tables outside ibdata1, this is a 24/7 nightmare because the tablespace id of the .ibd file may change if a table is dropped and recreated throughout the course of a business day. If you backup the .ibd with its tablespace id that day, you cannot restore it to it DB Folder by dropping it in. You also cannot do any tricks
ALTER TABLE tblname DISCARD TABLESPACEandALTER TABLE tblname IMPORT TABLESPACEbecause the tablespace id is hardcoded. You have to write some custom adhoc scripts to pull off such a miracle in conjunction withALTER TABLE tblname DISCARD TABLESPACEandALTER TABLE tblname IMPORT TABLESPACE.
- For tables inside ibdata1, mysqldump is your friend. 'NUFF SAID...
Code Snippets
ALTER TABLE mydb.mytable ENGINE=InnoDB;OPTIMIZE TABLE mydb.mytable;Context
StackExchange Database Administrators Q#9500, answer score: 3
Revisions (0)
No revisions yet.