Bug #28747 ALTER TABLE wipes cardinality statistics
Submitted: 29 May 2007 15:18 Modified: 8 Jun 2007 9:10
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:5.0-bk, 5.1-bk OS:Any
Assigned to: CPU Architecture:Any

[29 May 2007 15:18] Domas Mituzas
Description:
Once ALTER TABLE is run, 'SHOW INDEX' reports NULL cardinalities on MyISAM tables, though after OPTIMIZE they are not wiped.

How to repeat:
create table xt(a int primary key, b int unique, c int unique) engine=MyISAM;
insert into xt values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5);
alter table xt engine=MyISAM;
show index from xt;
optimize table xt;
show index from xt;

Suggested fix:
n/a
[4 Jun 2007 8:49] Sergei Golubchik
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php

The manual only says that after ANALYZE TABLE index cardinalities will be calculated. It does not claim that ALTER will preserve them or update them.
[4 Jun 2007 8:57] Domas Mituzas
Then documentation should be added about ALTER TABLE destroying index cardinality statistics and the need to run ANALYZE TABLES afterwards?
[8 Jun 2007 9:10] Stefan Hinz
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.