title: Postgres unique constraint vs index
body: <p>As I can understand <a href="https://www.postgresql.org/docs/current/indexes-unique.html" rel="noreferrer">documentation</a> the following definitions are equivalent:</p>
  
  <pre><code>create table foo (
      id serial primary key,
      code integer,
      label text,
      constraint foo_uq unique (code, label));
  
  create table foo (
      id serial primary key,
      code integer,
      label text);
  create unique index foo_idx on foo using btree (code, label);    
  </code></pre>
  
  <p>However, a note in <a href="https://www.postgresql.org/docs/9.4/indexes-unique.html" rel="noreferrer">the manual for Postgres 9.4</a> says:</p>
  
  <blockquote>
    <p>The preferred way to add a unique constraint to a table is <code>ALTER TABLE ... ADD CONSTRAINT</code>. The use of indexes to enforce unique constraints
    could be considered an implementation detail that should not be
    accessed directly.</p>
  </blockquote>
  
  <p>(Edit: this note was removed from the manual with Postgres 9.5.)</p>
  
  <p>Is it only a matter of good style? What are practical consequences of choice one of these variants (e.g. in performance)?</p>