title: Understanding the virtualxid transaction type in postgres
body: <p>I am trying to understand locks in postgres and here is what I have understood till now.</p>
  
  <ul>
  <li>pg_locks contains lock information</li>
  <li>All statements in postgres runs inside of a transaction either explicit/implicit. (Postgres 9.0 high performance)</li>
  </ul>
  
  <p>As per my understanding virtualxids are not real transactions and transactionidxid is what indicates a transaction.</p>
  
  <p>When I do a simple connect to the psql shell, and I query the pg_locks table there is already a virtualxid present there.</p>
  
  <p>I have not initiated a transaction or ran a query, so why this virtualxid is created ? Is it because that this connection might initiate a transaction in the future?</p>
  
  <p>What am I missing here?</p>