Difference between Version store and Row Versioning

  • Hi,

    Could anyone tell me the difference between Version store and Row Versioning?

    Or

    Both are same ?

    Regards,
    Saravanan

  • Row versioning and version store are different things.

    Row Versioning is what happens to rows. Every change to a row changes the row version Id.

    Row versioning has been available from at least SQL7 and in older versions of SQL Server the row version ID is stored in a DateTime data item. In recent versions of SQL Server DateTime Timestamp has been given a new name of RowVersion and currently both names can be used for this data item. Eventually in some future version of SQL Server the DateTime Timestamp name will become invalid.

    The Version Store is part of Snapshot Isolation. It is where SQL Server stores old version of rows if you are using Snapshot Isolation for a given transaction or have enabled snapshot isolation for the entire database.

    With snapshot isolation, updaters never block readers and readers never block updaters. However, it is still possible for updaters to block other updaters that need the same row.

    When you use snapshot isolation, each transaction is guaranteed to see the contents of rows as they existed at the start of that transaction. If a transaction updates a row that another transaction has an interest in, the old version of that row is saved in the version store. Any tranbsaction that started before the update transaction will be given the old version of the row, regardless of any locks that may be still held by the updating transaction.

    In SQL Server, the version store exists within tempdb. If you are familiar with Oracle, the version store in tempdb performs the same function as 'Rollback Segments' in Oracle.

    Edited to correct date type name (d'oh)

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

  • EdVassie (5/23/2011)


    Row versioning has been available from at least SQL7 and in older versions of SQL Server the row version ID is stored in a DateTime data item. In recent versions of SQL Server DateTime has been given a new name of RowVersion and currently both names can be used for this data item. Eventually in some future version of SQL Server the DateTime name will become invalid.

    I suspect he means row versioning as in snapshot isolation, not the timestamp/rowversion data type.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks for the reply!!

    I need the diffence between row versioning in Snaphot isolation(not data type) and version store?

    Regards,
    Saravanan

  • Row versioning isolation levels can improve concurrency because committed data can be read from the version store instead of acquiring locks on data read. All update and delete statements store pre-update versions of changed data in the tempdb version store once either the READ_COMMITTED_SNAPSHOT or ALLOW_SNAPSHOT_ISOLATION database option is turned on. SQL Server then returns these pre-update row versions to applications reading data in the READ_COMMITTED (with READ_COMMITTED_SNAPSHOT database option on) or SNAPSHOT transaction isolation levels. The main difference between row versioning in these isolation levels is that READ_COMMITTED is single-statement level and SNAPSHOT is transaction level (multi-statement). See Row Versioning-based Isolation Levels in the Database Engine in the Books Online for details.

  • Version store is where the row versions (created for snapshot isolation) are stored.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Version store is where the row versions (created for snapshot isolation) are stored.

    Could you elaborate on thie please ?

    Regards,
    Saravanan

  • What needs elaborating?

    Row versions are created with snapshot isolation level. They're historical versions of rows used for transactions/statements that began before the row was changed.

    The version store is the place those historical versions are stored.

    It's like asking what's the difference between a table and a row. A row is stored in a table. Row versions are stored in the version store.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • EdVassie (5/23/2011)


    Row versioning and version store are different things.

    Row Versioning is what happens to rows. Every change to a row changes the row version Id.

    Row versioning has been available from at least SQL7 and in older versions of SQL Server the row version ID is stored in a DateTime data item. In recent versions of SQL Server DateTime has been given a new name of RowVersion and currently both names can be used for this data item. Eventually in some future version of SQL Server the DateTime name will become invalid.

    <snip>

    Is there a different row version that is a date value or are you referring to RowVersion/Timestamp data type? If so that's an 8-byte number not a datetime. Just posting for clarity, as I've seen lots of people post in the past asking how to convert a Timestamp to a datetime and didn't want the OP to think RowVersion is a DateTime.

  • didn't want the OP to think RowVersion is a DateTime

    Due to a stange decision in the history of SQL Server, the data type known as DateTime Timestamp does not hold a date or time value. Instead, it holds a unique value that automatically changes every time the row is updated. This value cannot be converted to a date, nor a time, nor even a timestamp. Microsoft realised this problem when designing SQL 2005 and currently there are two names for this data type: DateTime Timestamp and RowVersion. In due course the DateTime Timestamp name will be taken out of SQL Server.

    Many other DBMS systems use the name DateTime Timestamp to hold a timestamp value, and use RowVersion to hold a row version Id, but SQL Server is different.

    Edited to correct date type name

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

  • EdVassie (5/25/2011)


    didn't want the OP to think RowVersion is a DateTime

    Due to a stange decision in the history of SQL Server, the data type known as DateTime does not hold a date or time value. Instead, it holds a unique value that automatically changes every time the row is updated.

    That's timestamp. The DateTime datatype most certainly does hold a date and time value.

    It's TimeStamp that's actually a binary rowversion, not a time.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Gail :cool:. Just after I clicked Post I realised I had got this wrong. I have gone back and fixed my posts.

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply