Ouch you have innodb_file_per_table off
I wrote articles on this before. You will have to convert the InnoDB infrastructure.
Once you do this, anytime you do OPTIMIZE TABLE to an InnoDB, it will actually shrink.
If you do not perform the InnoDB infrastructure cleanup, the ibdata1 file will actually grow in size. To make matter worse, I think mysqltuner.pl is using a weird algorithm for determining InnoDB fragmentation. I tend to ignore it.
I check for fragmentation differently.
Back on April 19, 2012 I answered a question similar to this: How do you remove fragmentation from InnoDB tables?.
Here is what I said in that earlier post:
After running the above steps, how can you determine what tables need
to be defragmentated? It is possible to find out, but you will have
script it.
Here is an example: Suppose you have the table mydb.mytable
. With
innodb_file_per_table enabled, you have the file
/var/lib/mysql/mydb/mytable.ibd
You will have to retrieve two numbers
FILESIZE FROM OS : You can ascertain the filesize from the OS like
this
ls -l /var/lib/mysql/mydb/mytable.ibd | awk '{print $5}'
FILESIZE FROM INFORMATION_SCHEMA : You can ascertain the filesize from
information_schema.tables like this:
SELECT (data_length+index_length) tblsize FROM information_schema.tables
WHERE table_schema='mydb' AND table_name='mytable';
Just subtract INFORMATION_SCHEMA value from OS value and divide the
difference by the INFORMATION_SCHEMA value.
From there you would decide what percentage deems it necessary to defrag that table. In other words, if there is a big difference between the filesize of the .ibd
file and the number from INFORMATION_SCHEMA.TABLES, go ahead with OPTIMIZE TABLE
. Regardless of the filesize, please don't worry if the fragmentation is less than 1%.
SHOW VARIABLES LIKE 'innodb_file_per_table';
and tell me, is it enabled or disabled ???OPTIMIZE
andREPAIR
on InnoDB tables (or provide links to his previous answers).