The most compact way to store data is to store binary bytes using the VARBINARY data type, not a string with the utf8_bin setting.Calculate your digital hash of your image, convert to a string of hexadecimal digits, then use UNHEX () to convert to binary bytes. Binary bytes are stored in half the space of an equivalent string of hexadecimal digits. For example, a type string 'FFFF'requires four characters, but UNHEX('FFFF')is stored in two binary bytes.
Saving in a more compact way is just a small performance improvement.
The best performance advantage is to use an index. But InnoDB has a limit on the length of the index. The default limit is 767 bytes.
innodb_large_prefix=1, InnoDB 3072 ( DYNAMIC COMPRESSED, , ). , .
: , innodb_large_prefix MySQL 5.7.7 MariaDB 10.2, . , , . , .
CREATE TABLE MyTable (
dhash VARBINARY(3072) NOT NULL,
UNIQUE KEY (dhash)
);