title: Is it worth the trouble to use tinyint instead of int for SqlServer lookup tables?
body: <p>When designing a lookup table (enum) in SqlServer 2005, if you know the number of entries will never get very high, should you use tinyint instead of int?  I'm most concerned about performance, particularly efficiency of indexes.</p>
  
  <p>Let's say you have these representative tables:</p>
  
  <pre><code>Person
  ------
  PersonId int  (PK)
  PersonTypeId tinyint  (FK to PersonTypes)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>PersonTypes
  -----------
  PersonTypeId tinyint
  PersonTypeName varchar(50)
  </code></pre>
  
  <p>The obvious factors are data size and coding hassle.  When we get to 100 million rows in the person table, we're storing 300 million less bytes with tinyint as opposed to int, plus the space taken up by our indexes.  Not a huge amount of data, but significant if the design decision is applied to dozens of big tables.  The coding hassle, of course, comes from all those casting problems back in the ASP.NET C#/VB code.</p>
  
  <p>If we set aside those two issues, what else comes into play?  Will queries be much more efficient due to the decreased size of the index pages?  Or is there some sort of padding that happens that will just negate the benefits?  Any other gotchas?</p>
  
  <p>I've always just used ints personally, but I'm considering tinyint for an upcoming redesign/migration effort on some huge tables, so I'd love to get some advice.</p>
  
  <p>[Edit]</p>
  
  <p>After experimenting with this, the coding hassles I anticipated turned out to be a non-issue.  Changing from int to tinyint hasn't resulted in any casting problems at all.</p>