title: How to ignore duplicates without unique constraint in Postgres 9.4?
body: <p>I am currently facing an issue in our old database(postgres 9.4) table which contains some duplicate rows. I want to ensure that no more duplicate rows should be generated. </p>
  
  <p>But I also want to keep the duplicate rows that already has been generated. Due to which I could not apply unique constraint on those columns(multiple column). </p>
  
  <p>I have created a trigger which would check the row if already exists and raise exception accordingly. But it is also failing when concurrent transactions are in processing.</p>
  
  <p>Example : </p>
  
  <pre><code>TAB1
  
  col1   |  col2  |  col3  |
  ------------------------------------
  1      |  A     |  B     |   -- 
  2      |  A     |  B     |   -- already present duplicates for column col2 and col3(allowed)
  3      |  C     |  D     |
  
  INSERT INTO TAB1 VALUES(4 , 'A' , 'B') ; -- This insert statement will not be allowed.
  </code></pre>
  
  <p><strong>Note:</strong> I cannot use <strong>on conflict</strong> due to older version of database.</p>