title: Change varchar to boolean in PostgreSQL
body: <p>I've started working on a project where there is a fairly large table (about 82,000,000 rows) that I think is very bloated. One of the fields is defined as:</p>
  
  <pre><code>consistency character varying NOT NULL DEFAULT 'Y'::character varying
  </code></pre>
  
  <p>It's used as a boolean, the values should always either be ('Y'|'N').  </p>
  
  <p>Note: there is no check constraint, etc.  </p>
  
  <p>I'm trying to come up with reasons to justify changing this field. Here is what I have:</p>
  
  <ul>
  <li>It's being used as a boolean, so make it that.  Explicit is better than implicit.</li>
  <li>It will protect against coding errors because right now there anything that can be converted to text will go blindly in there.</li>
  </ul>
  
  <p>Here are my question(s).  </p>
  
  <ul>
  <li>What about size/storage? The db is UTF-8. So, I <em>think</em> there really isn't much of a savings in that regard.  It should be 1 byte for a <code>boolean</code>, but also 1 byte for a <code>'Y'</code> in UTF-8 (at least that's what I get when I check the length in Python). Is there any other storage overhead here that would be saved?</li>
  <li>Query performance?  Will Postgres get any performance gains for a where cause of "<code>=TRUE</code>" vs. "<code>='Y'</code>"?</li>
  </ul>