title: Does the order of columns in a Postgres table impact performance?
body: <p>In Postgres does the order of columns in a <code>CREATE TABLE</code> statement impact performance? Consider the following two cases:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE foo (
    a      TEXT, 
    B      VARCHAR(512),
    pkey   INTEGER PRIMARY KEY,
    bar_fk INTEGER REFERENCES bar(pkey),
    C      bytea
  ); 
  </code></pre>
  <p>vs.</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE foo2 (
    pkey   INTEGER PRIMARY KEY,
    bar_fk INTEGER REFERENCES bar(pkey),
    B      VARCHAR(512),      
    a      TEXT, 
    C      bytea
  );
  </code></pre>
  <p>Will performance of <code>foo2</code> be better than <code>foo</code> because of better byte alignment for the columns? When Postgres executes <code>CREATE TABLE</code> does it follow the column order specified or does it re-organize the columns in optimal order for byte alignment or performance?</p>