I need to put an index on a md5 hash column in the database. I will perform searches on the md5 column. I was going to store the hash as a CHAR(32) but I seen the binary column option as well. Will storing a md5 hash work better in a binary column or a char(32). Can i use Linq to Entities to query a binary column? If so, How would I go about this?
Share
If you are using SQLServer or any other server that supports 128 bit GUID types… you can use the GUID type to express an MD5 value.
Since MD5 is 16 byte (128 bit) you can easily convert it to a GUID.
For doing that in C# you can use the Guid structure and\or write simple conversion routines by hand.
Guids are in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where x is an hexadecimal character, but are internally stored as 128 bit integers, so, they occupy very little amount of space and are very, very fast for queries!
GUIDS works much better than char or binary, they are fixed size and are often used as keys\indices instead of INT when more bits are needed due to their very high speed and low space consumption.