I have a table in which a column stores image src which is in hash value and that hash value is generated from microtime(),Now I have two choice storing directly hash value in database or storing that bigint microtime from which the image name is derived.Which would make my db faster.
We have to analyze this from all sides to asses what speed faults are incured.
I will make a few assumptions:
As @Namphibian stated is composed of 2 operations for the BIGINT versus 3 operations for the CHAR.
But the speed difference in my opinion really isn't that big. You can run 10.000.000 continuous calculations (in a while
loop) and benchmark them to find out the real difference between them.
Also a speed difference in the application code affects users linearly, while speed differences in the DB affect users nonlinearly when traffic increases because overlapping writes have to wait for each other and some reads have to wait for writes to finish.
Is almost the same for a BIGINT as it is for a CHAR(40) or a BINARY(20) because the more serious time consumption is done waiting for access to the disk rather than actually writing to it.
This is always faster for a BIGINT compared to a CHAR(40) or a BINARY(20) for two reasons:
Second best option is the BINARY(20) because it saves some space and it is easier to compare due to reduced length.
Both BINARY(20) and CHAR(40) are the result of the hashing mechanism and are randomized, hence comparing and sorting takes a longer time on average because randomized data in indexes (for a btree index) needs more tree traversals to fetch (i mean that in the context of multiple values, not for one single value).