Simple Comparison of Space Usage and Performance Between MySQL MYROCKS and MyISAM

Test hash table with around 10 million rows, with three columns: sha256, md5, qq, and two unique indexes.

MyISAM

Not compressed with myisampack

The result was 1004MB, then we proceeded with table compression and index rebuilding

cd /www/server/mysql/data/hash2
myisampack email_hash_1
myisamchk -rq email_hash_1

The process was very slow, and the size after completion is as follows

It can be seen that the space usage is reduced by about 50% compared to the uncompressed version, with a final size of 639MB.

Note that after compressing a MyISAM table, write operations will no longer be possible, and it may affect performance during multi-row queries.

MyRocks

MyRocks table files are stored dispersedly, so you cannot directly observe the files, but you can check them via phpMyAdmin.

The display doesn’t seem very accurate, so we further confirmed by comparing the size of the .rocksdb folder before and after import.

image

It can be seen that the actual occupied size is 835MB, which has a large deviation from what phpMyAdmin displayed.

Conclusion

The smallest table space usage is achieved by the compressed MyISAM, but it has many drawbacks.

There is also a small easter egg: after enabling ZSTD compression for MyRocks, the actual effect is extremely impressive, leaving it for readers to explore on their own.