Recently I think about the best practices with storing historical data in MySQL database. For now, each versionable table has two columns - valid_from
and
I'm nearing completion of an application which does exactly this. Most of my indexes index by key fields first and then the valid_to
field which is set to NULL
for current records thereby allowing current records to be found easily and instantly. Since most of my application deals with real time operations, the indexes provide fast performance. Once in a while someone needs to see historical records, and in that instance there's a performance hit, but from testing it's not too bad since most records don't have very many changes over their lifetime.
In cases where you may have a lot more expired records of various keys than current records it may pay to index over valid_to before any key fields.