title: PostgreSQL ADD COLUMN DEFAULT NULL locks and performance
body: <p>I have a table in my PostgreSQL 9.6 database with 3 million rows. This table already has a null bitmap (it has 2 other <code>DEFAULT NULL</code> fields). I want to add a new boolean nullable column to this table. I stuck with the difference between these two statements:</p>
  
  <pre><code>ALTER TABLE my_table ADD COLUMN my_column BOOLEAN;
  ALTER TABLE my_table ADD COLUMN my_column BOOLEAN DEFAULT NULL;
  </code></pre>
  
  <p>I think that these statements have no difference, but:</p>
  
  <ol>
  <li>I can't find any proof of it in documentation. Documentation tells that providing <code>DEFAULT</code> value for the new column makes PostgreSQL to rewrite all the tuples, but I don't think that it's true for this case, cause default value is <code>NULL</code>.</li>
  <li>I ran some tests on copy of this table, and the first statement (without <code>DEFAULT NULL</code>) took a little bit more time than the second. I can't understand why.</li>
  </ol>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Will PostgreSQL use the same lock type (<code>ACCESS EXCLUSIVE</code>) for those two statements?</li>
  <li>Will PostgreSQL rewrite all tuples to add <code>NULL</code> value to every of them in case that I use <code>DEFAULT NULL</code>?</li>
  <li>Are there any difference between those two statements?</li>
  </ol>