title: Transaction time out workaround for PostgreSQL
body: <p>AFAIK, PostgreSQL 8.3 does not support transaction time out.  I've read about supporting this feature in the future and there's some discussion about it.  However, for specific reasons, I need a solution for this problem.  So what I did is a script that runs periodically: </p>
  
  <p>1) Based on locks and activity, query in order to retrieve processID of the transactions that is taking too long, and keeping the oldest (<em>trxTimeOut.sql</em>):</p>
  
  <pre><code>SELECT procpid
  FROM
  (
      SELECT DISTINCT age(now(), query_start) AS age, procpid
      FROM pg_stat_activity, pg_locks
      WHERE pg_locks.pid = pg_stat_activity.procpid
  ) AS foo
  WHERE age &gt; '30 seconds'
  ORDER BY age DESC
  LIMIT 1
  </code></pre>
  
  <p>2) Based on this query, kill the corresponding process (<em>trxTimeOut.sh</em>):</p>
  
  <pre><code>psql -h localhost -U postgres -t -d test_database -f trxTimeOut.sql | xargs kill
  </code></pre>
  
  <p>Although I've tested it and seems to work, I'd like to know if it's an acceptable approach or should I consider a different one?</p>