4

Sorry for my bad English :)

I need a help with understanding version store`s cleaning. I have the following situation.

  1. 12:00 Start a select statement under the snapshot isolation level and not commit.
  2. 12:01 Start an update statement (update a single row) under the read committed isolation level and commit.
  3. 12:02 Start a select statement under the snapshot isolation level and not commit.
  4. 12:03 Start an update statement (update a single row) under the read committed isolation level and commit.

Now if we look at the version store such as

SELECT *
FROM sys.dm_tran_version_store

We will see there are 2 rows (one row for each update statement).

Now if we commit the first transactions that starts at 12:00, no row is being removed from the version store (even past a minute).

The question is WHY???.

In my opinion one of the rows have to be removed from the version store, because there are no active transactions, that have access to that version.

I tried also to update no 1 row, but 100 rows (Total more then 100 KB) but I have the same situation, the version store is not being removed.

Please help me to understand when the version store is being cleaned.

1 Answer 1

3

Now if we commit the first transactions that starts at 12:00, no row is being removed from the version store (even pass a minute).

The question is WHY ?

Minimal condition for a version row to be garbage collected is when SQL Server determines, based on the transactional states, that this version is no longer needed.

Also, referring to my SQL Server internals notes, for management of version store, SQL Server will perform a regular cleanup every minute with a background process to reclaim all the reusable space from the version store.

You can monitor Version generation rate and version cleanup rate in SQLServer:Transactions perfmon counter to find out rate at which space is acquired and released from version store in KB/Sec.

Check : Managing TempDB in SQL Server: TempDB Basics (Version Store: Simple Example)

1
  • And the second questions is - when does the SQL Server determines, that the version is no longer need? In my case only the transaction started in 12:00 need the version created in the 12:01 because of update. But the transaction started in 12:00 is committed, and the 1 minute is past, but version store has not been cleaned. Commented May 13, 2015 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.