Random insertions into or deletions from a secondary index can cause the index to become fragmented. Fragmentation means that the physical ordering of the index pages on the disk is not close to the index ordering of the records on the pages, or that there are many unused pages in the 64-page blocks that were allocated to the index.
One symptom of fragmentation is that a table takes more space than it “should” take.
All InnoDB data and indexes are stored in B-trees, and their fill factor may vary from 50% to 100%. Another symptom of fragmentation is that a table scan such as this takes more time than it “should” take.
To speed up index scans, you can periodically perform a “null” ALTER TABLE operation, which causes MySQL to rebuild the table
- ALTER TABLE tbl_name ENGINE=INNODB
Note:
- You can also use ALTER TABLE tbl_name FORCE to perform a “null” alter operation that rebuilds the table.
- As of MySQL 5.7.4, both ALTER TABLE tbl_name ENGINE=INNODB and ALTER TABLE tbl_name FORCE use online DDL (ALGORITHM=COPY).
References:
http://dev.mysql.com/doc/refman/5.7/en/innodb-file-defragmenting.html
One symptom of fragmentation is that a table takes more space than it “should” take.
All InnoDB data and indexes are stored in B-trees, and their fill factor may vary from 50% to 100%. Another symptom of fragmentation is that a table scan such as this takes more time than it “should” take.
To speed up index scans, you can periodically perform a “null” ALTER TABLE operation, which causes MySQL to rebuild the table
- ALTER TABLE tbl_name ENGINE=INNODB
Note:
- You can also use ALTER TABLE tbl_name FORCE to perform a “null” alter operation that rebuilds the table.
- As of MySQL 5.7.4, both ALTER TABLE tbl_name ENGINE=INNODB and ALTER TABLE tbl_name FORCE use online DDL (ALGORITHM=COPY).
References:
http://dev.mysql.com/doc/refman/5.7/en/innodb-file-defragmenting.html
No comments:
Post a Comment