title: Executing Postgres statement or procedure without waiting for return
body: <p>I'd like to invoke some cleanup procedure after some INSERT is done, and the cleanup takes a long time. My sql client has very little tolerance on timeouts, so I'd like to return as soon as the command is issued. </p>
  
  <p>I've tried Trigger --the INSERT triggers the stored procedure to do cleanup. The problem is that now the INSERT has to wait for the cleanup to finish in order to return.</p>
  
  <p>I've tried calling a 'proxy' function which then calls the actual cleanup function, but it seems that the function call stack in Postgres is no different than in other languages. The client still waits for the cleanup. </p>
  
  <p>What's the best practice in this scenario? Thanks!</p>