When i run optimize table on a innodb table, i get this message instead. does it mean that the table has already been optimized, but in a different manner?
"table | optimize | note | Table does not support optimize, doing recreate + analyze instead |"
OPTIMIZE TABLE works for InnoDB , MyISAM , and ARCHIVE tables. OPTIMIZE TABLE is also supported for dynamic columns of in-memory NDB tables. It does not work for fixed-width columns of in-memory tables, nor does it work for Disk Data tables.
The MySQL OPTIMIZE table helps you to optimize the table storage space. It reorganizes the storage data in a way that increases the Input Output efficiency and reduces the storage space. To execute this statement, you need SELECT and INSERT privileges.
OPTIMIZE is 'safe' in all respects since it locks the table, copies all the data over, then renames the new copy in place of the old.
From the documentation:
For InnoDB tables, OPTIMIZE TABLE is mapped to ALTER TABLE, which rebuilds the table to update index statistics and free unused space in the clustered index. Beginning with MySQL 5.1.27, this is displayed in the output of OPTIMIZE TABLE when you run it on an InnoDB table, as shown here:
mysql> OPTIMIZE TABLE foo;
+----------+----------+----------+-----------------------------------------------------------
| Table | Op | Msg_type | Msg_text
+----------+----------+----------+-----------------------------------------------------------
| test.foo | optimize | note | Table does not support optimize, doing recreate + analyze ...
| test.foo | optimize | status | OK
+----------+----------+----------+-----------------------------------------------------------
You can make OPTIMIZE TABLE work on other storage engines by starting mysqld with the --skip-new or --safe-mode option. In this case, OPTIMIZE TABLE is just mapped to ALTER TABLE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With