Bug #1244 Disable/Enable keys always rebuilds indexes
Submitted: 11 Sep 2003 1:14 Modified: 10 Dec 2003 6:58
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S4 (Feature request)
Version:4.0.15 OS:Linux (Linux)
Assigned to: Michael Widenius CPU Architecture:Any

[11 Sep 2003 1:14] [ name withheld ]
Description:
I have a sample MyISAM table with some millions lines which has one key on an int field:
CREATE TABLE test (a int, KEY a (a));
Before loading the data in I disabled keys and after that re-enabled again. As expected it took some time for the index to be built. However ENABLE KEYS seems to always rebuild the indexes even if there was no insert after DISABLE:

mysql> ALTER TABLE test DISABLE KEYS;
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE test ENABLE KEYS;
Query OK, 0 rows affected (4.94 sec)

mysql> ALTER TABLE test DISABLE KEYS;
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER TABLE test ENABLE KEYS;
Query OK, 0 rows affected (4.93 sec)

It doesn't seem to be a correct behaviour...

How to repeat:
CREATE TABLE test (a int, KEY a (a));
ALTER TABLE test DISABLE KEYS;
Insert some millions lines of data.
ALTER TABLE test ENABLE KEYS;

Then disable and re-enable KEYS without any other action in between.
[15 Sep 2003 10:01] Indrek Siitan
Yes, currently the indexes are always rebuilt, but it can be fixed.
[10 Dec 2003 6:58] Michael Widenius
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

This is expected behaviour.  (We don't want to track if indexes needs to be rebuilt or not as this is not a common problem)