The InnoDB that comes with MySQL as of 5.6.11 has a serious flaw when it comes to utilizing the Fast Index Creation offered by MySQL when running optimize table queries. This is a verified bug which was reported a long time ago and the link to the bug is here. The reason why InnoDB still doesn't have this feature is because I guess Oracle thinks that this is more a feature than a bug. Percona Server has resolved this issue in their XtraDB storage engine but it comes at a cost :)
So i have a table with one primary key and one secondary key and the definition of the table is below. The table is populated with 240753 records. The information schema tells that the data length of the table is 22593536 and the innodb_buffer_pool_size is 5242880. So the table size is approximately 4 times the buffer size.
CREATE TABLE test (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
md5hash char(64) DEFAULT NULL,
PRIMARY KEY (id),
KEY mykey (md5hash)
) ENGINE=InnoDB AUTO_INCREMENT=240573 DEFAULT CHARSET=latin1;