Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there any way to find out the fragmentation of indexes in MySQL ?

If such an output can be obtained, it would be helpful to identify which all indexes need to be rebuilt.

I'm using MySQL 5.1 on Windows Server 2008

Can somebody please help me.

share|improve this question
    
Are you using InnoDB, MyISAM, or a mixture of both ??? –  RolandoMySQLDBA Feb 11 '13 at 16:55
    
If you are using InnoDB, do you have innodb_file_per_table configured ??? –  RolandoMySQLDBA Feb 11 '13 at 16:56
    
I'm using InnoDB with "innodb_file_per_table" –  Minto Mohan Feb 12 '13 at 4:22
add comment

1 Answer 1

For InnoDB tables, this is both possible and redundant. It is possible using Percona Server's INNODB_INDEX_STATS table in INFORMATION_SCHEMA. This table shows you the number of pages per index in an InnoDB tables.

Well, apparently InnoDB manages its own pages very well. Upon purging of data it merges back its index nodes. I have done multiple tests to verify that an OPTIMIZE TABLE -- a complete rebuild of the table -- does not actually improve on index fragmentation.

Please see my post on the subject.

By the way, I believe MySQL 5.6 has a similar table built-in.

With regard MyISAM tables, I'm unaware that there's any way of looking at the fragmentation.

share|improve this answer
    
Thanks for your comment. But as far as i know, the Percona server is available for Linux systems only. –  Minto Mohan Feb 11 '13 at 8:32
    
Yes, you are correct. I should have noticed that. –  Shlomi Noach Feb 11 '13 at 17:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.