title: Database Content Versioning
body: <p>I am interested in keeping a running history of every change which has happened on some tables in my database, thus being able to reconstruct historical states of the database for analysis purposes.  </p>
  
  <p>I am using Postgres, and this MVCC thing just seems like I should be able to exploit it for this purpose but I cannot find any documentation to support this.  Can I do it?  Is there a better way?</p>
  
  <p>Any input is appreciated!</p>
  
  <p><strong>UPD</strong></p>
  
  <p>I have marked Denis' response as the answer, because he did in fact answer whether MVCC is what I want which was the question.  However, the strategy I have settled on is detailed below in case anyone finds it useful:</p>
  
  <p>The Postgres feature that does what I want: online backup/point in time recovery.</p>
  
  <p><a href="http://www.postgresql.org/docs/8.1/static/backup-online.html" rel="noreferrer">http://www.postgresql.org/docs/8.1/static/backup-online.html</a> explains how to use this feature but essentially you can set this "write ahead log" to archive mode, take a snapshot of the database (say, before it goes live), then continually archive the WAL.  You can then use log replay to recall the state of the database at any time, with the side benefit of having a warm standby if you choose (by continually replaying the new WALs on your standby server).</p>
  
  <p>Perhaps this method is not as elegant as other ways of keeping a history, since you need to actually build the database for every point in time you wish to query, however it looks extremely easy to set up and loses zero information.  That means when I have the time to improve my handling of historical data, I'll have everything and will therefore be able to transform my clunky system to a more elegant system.</p>
  
  <p>One key fact that makes this so perfect is that my "valid time" is the same as my "transaction time" for the specific application- if this were not the case I would only be capturing "transaction time".</p>
  
  <p>Before I found out about the WAL, I was considering just taking daily snapshots or something but the large size requirement and data loss involved did not sit well with me.</p>
  
  <p>For a quick way to get up and running without compromising my data retention from the outset, this seems like the perfect solution.</p>
  
  <p></p>