Table optimization is a necessary evil; tables sometimes need to be optimized to reclaim space or to improve query performance. Unfortunately, MySQL blocks writes to a table while it is being optimized. Because optimization time is proportional to the table size, writes can be blocked for a long time. Fractal Tree indexes support online optimization; however, the MySQL metadata lock gets in the way of writing while optimizing. We will describe a simple patch to MySQL that enables online optimization of TokuDB tables.
Why do tables need to be optimized? Here are some reasons.
- Insertions with random keys can result in a tree with underutilized leaf blocks. Many tree algorithms split nodes in half when they become full. If these nodes are stored in fixed sized blocks, like many B-trees do, then there can be a lot of wasted space. Table optimization of