title: Postgres string data type storage allocation
body: <p>We are running Postgres 8.3.3 and the documentation (<a href="http://www.postgresql.org/docs/8.3/static/datatype-character.html" rel="nofollow noreferrer"><a href="http://www.postgresql.org/docs/8.3/static/datatype-character.html" rel="nofollow noreferrer">http://www.postgresql.org/docs/8.3/static/datatype-character.html</a></a>) leaves me with a few questions about how storage is allocated.</p>
  
  <p>For the purposes of this discussion I'd like to stick to assuming a character = 1 byte.</p>
  
  <p>I understand that character(n) blank pads so you always have n bytes stored.</p>
  
  <p>If your char(n) > 126 characters long, you have an overhead of 4 bytes (presumably for storing the length), otherwise an overhead of 1 byte.</p>
  
  <p>I'm interested in what happens with varchar(n).</p>
  
  <p>If I use varchar(255) and store a 4 character string in it, do I have 4 bytes for the string &amp; 4 bytes overhead, or do I have just one byte overhead until I hit the 126 character limit?</p>
  
  <p>I've googled and can't find this documented anywhere.</p>
  
  <p>Any thoughts?</p>