I’ve used the OPTIMIZE command for a long
time, in particular for disk space problems.
But I recently had a problem with this command and an
auto-incremented table, you can reproduce this problem like that
:
Create a table with an auto-incremented column
:
mysql> use test
Database changed
mysql> create table test_optimize (id int(8) unsigned NOT NULL
AUTO_INCREMENT, PRIMARY KEY (id)) engine=InnoDB;
Query OK, 0 rows affected (1.09 sec)
mysql> insert into test_optimize values (1),(2),(3),(4);
Query OK, 4 rows affected (0.28 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> show table status like ‘test_optimize’\G
*************************** 1. row
***************************
Name: …
[Read more]