title: Why historically do people use 255 not 256 for database field magnitudes?
body: <p>You often see database fields set to have a magnitude of 255 characters, what is the traditional / historic reason why? I assume it's something to do with paging / memory limits, and performance but the distinction between 255 and 256 has always confused me.</p>
  
  <pre><code>varchar(255)
  </code></pre>
  
  <p>Considering this is a capacity or magnitude, <em>not an indexer</em>, <strong>why is 255 preferred over 256?</strong> Is a byte reserved for some purpose (terminator or null or something)?</p>
  
  <p>Presumably varchar(0) is a nonsense (has zero capacity)? In which case 2^8 of space should be 256 surely?</p>
  
  <p>Are there other magnitudes that provide performance benefits? For example is varchar(512) less performant than varchar(511) or varchar(510)?</p>
  
  <p>Is this value the same for all relations databases, old and new?</p>
  
  <p><strong>disclaimer</strong> - I'm a developer not a DBA, I use field sizes and types that suit my business logic where that is known, but I'd like to know the <em>historic</em> reason for this preference, even if it's no longer relevant (but even more if it still is relevant).</p>
  
  <h2>Edit:</h2>
  
  <p>Thanks for the answers, there seems to be some concensus that a byte is used to store size, but this doesn't settle the matter definitively in my mind.</p>
  
  <p>If the meta data (string length) is stored in the same contiguous memory/disk, it makes some sense. 1 byte of metadata and 255 bytes of string data, would suit each other very nicely, and fit into 256 contiguous bytes of storage, which presumably is neat and tidy.</p>
  
  <p>But...If the metadata (string length) is stored separately from the actual string data (in a master table perhaps), then to constrain the length of string's data by one byte, just because it's easier to store only a 1 byte integer of metadata seems a bit odd.</p>
  
  <p>In both cases, it would seem to be a subtlety that probably depends on the DB implementation. The practice of using 255 seems pretty widespread, so someone somewhere must have argued a good case for it in the beginning, can anyone remember what that case was/is? Programmers won't adopt any new practice without a reason, and this must have been new once.</p>