Re: MVCC implementation
Date: 21 Jul 2006 09:54:07 -0700
Hmmm... I usually only think of MVCC as an alternative locking strategy really. It allows you to do away with locking for read, unless you explicitly ask for locks.
The easiest place to get info on MVCC is probably PostgreSQL. It used to be called "time travel" and was used as a way of looking at an "old" version of the database, and normal spin locks were still used for reads. Sometime (about 6.5.2 or thereabouts, IIRC) "time travel" per se was dropped, read locks were dropped unless explicitly requested and MVCC appeared. (I remember this because I used to run PostgreSQL on an Amiga under NetBSD, and the spinlock() routine didn't work so I couldn't use versions prior to the introduction of MVCC...) If the worst comes to the worst, you could always read the code ;)
MVCC works in PostgreSQL because it was designed from the start never to update a row in place; it always writes a new row instead. The 'vacuum analyze' statement becomes your friend very quickly (it gets rid of old row versions and updates stats for the optimizer). The whole MVCC thing didn't interest me that much, compared with the enthusiastic support for alternative data types and procedure languages. Sadly, I think POSTQUEL got dumped ages ago in favour of SQL ... sigh ...