Subject | Re: [firebird-support] Re: Question about Record Versioning??? |
---|---|
Author | Ann W. Harrison |
Post date | 2005-04-20T17:33Z |
Adam wrote:
with the transaction id of the transaction that created it. Identifying
the record versions that can be deleted is a slightly complicated - but
very quick - process.
The database keeps a list of the state of transactions - Active,
Committed, Rolled Back, and Limbo. The list doesn't go back to the time
the database was created, only to the first "interesting" transaction.
Older transactions are assumed to be committed. When you run sweep and
it removes all the changes of a rolled back transaction, it changes the
state of those transactions from "Rolled Back" to "Committed", so
they're no longer interesting. That's what's good about sweeping from
time to time.
The database also keeps track of the oldest transaction whose results
can not be seen by an active transaction. That's called the oldest
snapshot.
With those two pieces of information, a transaction can identify record
versions that can be removed.
1) Any record versions created by a transaction that rolled back can
be removed immediately.
2) Any record deleted by a transaction older than the oldest
snapshot can be removed completely.
3) Any record version with a newer version created by a transaction
older than the oldest snapshot can be removed, leaving newer versions.
Even more stuff you didn't ask for...
Regards,
Ann
>That's slightly misleading. Record versions aren't "marked", except
>
>>if in one program(only one user), one query have select from a
>> table A, and other query update the table A and commit,
>>then firebird will keep the record version?
>
>
> In this case (assuming one connection and one transaction) probably
> not. The old version will be marked for garbage collection.
with the transaction id of the transaction that created it. Identifying
the record versions that can be deleted is a slightly complicated - but
very quick - process.
The database keeps a list of the state of transactions - Active,
Committed, Rolled Back, and Limbo. The list doesn't go back to the time
the database was created, only to the first "interesting" transaction.
Older transactions are assumed to be committed. When you run sweep and
it removes all the changes of a rolled back transaction, it changes the
state of those transactions from "Rolled Back" to "Committed", so
they're no longer interesting. That's what's good about sweeping from
time to time.
The database also keeps track of the oldest transaction whose results
can not be seen by an active transaction. That's called the oldest
snapshot.
With those two pieces of information, a transaction can identify record
versions that can be removed.
1) Any record versions created by a transaction that rolled back can
be removed immediately.
2) Any record deleted by a transaction older than the oldest
snapshot can be removed completely.
3) Any record version with a newer version created by a transaction
older than the oldest snapshot can be removed, leaving newer versions.
Even more stuff you didn't ask for...
Regards,
Ann