cockroachdb/cockroach — pull request #122 by spencerkimball (2014-10-10 17:47:50+00:00)
Title: Added MVCC stats.

Stats include the following:
- Live key/values (i.e. what a scan at current time will reveal;
note that this includes intent keys and values, but not keys and
values with most recent value deleted)
- Key bytes (includes all keys, even those with most recent value deleted)
- Value bytes (includes all versions)
- Key count (count of all keys, including keys with deleted tombstones)
- Value count (all versions, including deleted tombstones)
- Intents (provisional values written during txns)

They are computed by MVCC incrementally on all updates to be applied
by the range after a successful execution of a command. Stats will be
applied as merged counters to efficiently track stats for ranges in
order to decide whether to split.

There is also a means to recompute stats for an arbitrary key range.
In this mode, the engine is directly scanned and the stats are computed
from the raw data. This method is used to compare against the incremental
counts in a randomized unittest.