title: Does the use of VARCHAR(8) and VARCHAR(32) occupies the same space in database?
body: <p>I have made a site where the files' name will be stored as <code>MD5</code> hash.</p>
  
  <p>If I'm not wrong then a collision is bound to occur after <strong>2^128</strong> times, ignoring the repetitions. I have found a <a href="https://stackoverflow.com/questions/201705/how-many-random-elements-before-md5-produces-collisions">thread</a> on this here and I'm satisfied with the probability of collision. It's almost 0.</p>
  
  <p>However, I thought instead of using 32(<a href="https://stackoverflow.com/questions/7124029/mysql-varchar-size">+1</a>) byte, declaring the column in the DB table as <code>VARCHAR(32)</code>, I can use as 8(<a href="https://stackoverflow.com/questions/7124029/mysql-varchar-size">+1</a>) byte for the name to save space. The probability of collision is <strong>1/2^32</strong>, ignoring the repetitions.</p>
  
  <p>To test this I altered the column to <code>VARCHAR(8)</code>, keeping all the records same, about 260 entries, and checked the DB size but there was no change in the size of DB.</p>
  
  <p>The formula I'm using is :</p>
  
  <pre><code>$temp = mysql_query("SHOW TABLE STATUS");  
  $size = 0;
  while($row = mysql_fetch_array($temp)) {  
       $size += $row["Data_length"] + $row["Index_length"];  
  }
  </code></pre>
  
  <p>Got help from <a href="https://stackoverflow.com/questions/14714750/how-to-get-true-size-of-mysql-database">here</a>.</p>
  
  <p>Even I tried with <code>FOREIGN KEY</code> reference in other tables where the files' names are being used but the size remained same as that of a table where I copied the full file name.</p>
  
  <p>Now my question is where am I going wrong? Is it in the calculation of the DB size or in determining the size of the datatype of the column?</p>
  
  <p>I'm not from a computer background and this is the first time I'm making a site so some points may sound silly to many. Sorry for that.</p>