Reputation:
In my database I have a hash and size fields. When I want to search this table I always have a size and hash to compare against. Which column should I index? I'm thinking the hash is a blob so maybe that datatype is not very good to check against even though I know they will be X bits wide (i haven't chosen but i think i'll use SHA256)
Should I index the hash column or size?
Upvotes: 1
Views: 1463
Reputation:
The hash should probably not be stored in a BLOB column -- it's of a small known size, and you will probably want to search it. Storing it in a BINARY column, or even just storing it in a VARCHAR in hex format, would be much more appropriate.
Once you've fixed that up, answering the question is simple: Will you be sorting or searching for rows based on the size or hash? If either of these is the case, then the column should be indexed. Otherwise, there's no need.
Upvotes: 5