PlanetScale

Generated Hash Columns in MySQL

Jun 15, 2023Aaron Francis
Generated Hash Columns in MySQL
SummaryAI, from the source post

This post introduces and details the use of generated hash columns in MySQL for optimizing indexed lookups. It explains how generated columns (STORED and VIRTUAL) work, demonstrates their use for calculating derived values like radius and area, and then focuses on creating generated hash columns using MD5. It covers scenarios for single large columns (like URLs) and multiple columns using CONCAT_WS, and discusses optimizing storage by using BINARY(16) for MD5 hashes with UNHEX. The post also addresses hash collision mitigation by using redundant conditions and highlights the benefits of compact indexes over wide composite indexes for specific lookup patterns.

More from the MySQL Integer Data Types trail