title: Does column order matter when defining unique constraints
body: <p>How is this</p>
  
  <pre><code>CREATE TABLE foo (
      id   SERIAL PRIMARY KEY,
      col1 VARCHAR(50) NOT NULL,
      col2 VARCHAR(50) NOT NULL,
      col3 DOUBLE PRECISION NULL,
      UNIQUE(col1, col2)
  );
  </code></pre>
  
  <p>Different from this?</p>
  
  <pre><code>CREATE TABLE foo (
      id   SERIAL PRIMARY KEY,
      col1 VARCHAR(50) NOT NULL,
      col2 VARCHAR(50) NOT NULL,
      col3 DOUBLE PRECISION NULL,
      UNIQUE(col2, col1) -- reversed column ordering
  );
  </code></pre>
  
  <p>From what I understand both commands will generate an index on the two columns to enforce the unique constraint but with different ordering.</p>
  
  <p>So I would not need to generate a separate index to speed up queries like this in either case.</p>
  
  <pre><code>SELECT id, col3 FROM foo WHERE col1 = 'stack' AND col2 = 'overflow'
  </code></pre>
  
  <p>However if future queries will also involve querying by column "col2" alone like below the latter form is preferred because the index will still be usable right?</p>
  
  <pre><code>SELECT id, col3 FROM foo WHERE col2 = 'overflow'
  </code></pre>