title: How does unique constraint affect write performance in Postgres DB
body: <p>Does the <code>UNIQUE</code> constraint specified on a column or group of columns affect the write performance of Postgres DB in any way? How does it internally function? </p>
  
  <p>I mean, does it perform unique checking at the time of insertion of a new record? If yes, how does it do that, does it do a linear search for a duplicate value already existing in the DB? In that case, it is deemed to affect the performance i.e. more the number of unique constraints worse would be the write/insert performance? Is it true? </p>