title: MD5 and SHA hash functions in MYSQL
body: <p>I've implemented the optimistic in mysql database using MD5 and SHA-1 and everything work well. 
  My problem is that i don't know if this is the best solution as i don't know how much time mysql take to calculate each hash.
  Here is the method </p>
  
  <pre><code>select field1 , field2 ,sha1(field1),md5(field2) from mytable
  where id = someValueHere
  
  update mytable set column1=value1,column2=value2
  where id= someValueHere  
  and sha1(field1) = storedValue 
  </code></pre>
  
  <p>this method gives you the possibily to not touch your databse or make changes on it. But as i've mentionned i need to know more details about performance of this method.</p>