title: How to handle concurrent request in postgres?
body: <p>Scenario:- There is a table X. When new request comes, using 'select' the existence of record is checked if not found using insert the data is inserted into table. Once 'insert' happens Trigger gets fired on Table X</p>
  
  <p>Issue:- Time taken for insert is 10 sec.
  When Select is fired (in 5 sec) till that time earlier insert is not completed. Hence multiple records are getting inserted. Moreover, trigger also gets fired again.</p>
  
  <p>How can this issue be resolved? Any suggestions to overcome this situation?</p>