Reputation: 2252
There are few data Types in MySQL, so I was wondering what is the best data type for storing hash values like RIPEMD-160.
I now that I could use a Text type but I only want to storage the space that hash algorithms need.
So, what are my alternatives?
Upvotes: 2
Views: 321
Reputation: 771
Since RIPEMD-160 transforms the string in a 160bit hash you can just use CHAR(40) (If you transform it in hex you'll be able to represent it in 40 char), otherwise, if you ever find yourself with a variable-lenght hashing algorithm, you can use VARCHAR, which will only occupy the space you need (with a little overhead).
For more info: mysql's reference
Upvotes: 1
Reputation: 713
It really depends on WHAT are you going to store, which means you have to answer yourself, what hash function are you going to use?
For RIPEMD-160, it always returns a 40byte string representing an hexadecimal number, so i would go with char(40).
Using char when the length is always the same provides a minor speed increase.
Upvotes: 1