HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

When are the unnecessary row versions being removed from the version store

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
fromunnecessarytheremovedareversionversionsstorebeingwhen

Problem

Sorry for my bad English :)

I need a help with understanding version stores cleaning. I have the following situation.

  • 12:00 Start a select statement under the snapshot isolation level and not commit.



  • 12:01 Start an update statement (update a single row) under the read committed isolation level and commit.



  • 12:02 Start a select statement under the snapshot isolation level and not commit.



  • 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.

Solution

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)

Context

StackExchange Database Administrators Q#101306, answer score: 3

Revisions (0)

No revisions yet.