SQL Server - Temporal Table - Storage costs

江枫思渺然 提交于 2019-12-24 23:23:14

问题


are there any information in the net, where i can verify how hight are the storage costs for temporal tables feature?

Will the server creates a the full hardcopy of the row/tuple that was modified? Or will the server use a reference/links to the original values of the master table that are not modified?

For example. I have a row with 10 columns = storage 100 KB. I change one value of that row, thow times. I have thow rows in the historical table after that changes. Is the fill storage cost for the master und historial table then ~300KB?

Thanks for every hint!

Ragards


回答1:


Will the server creates a the full hardcopy of the row/tuple that was modified? Or will the server use a reference/links to the original values of the master table that are not modified?

Here is the cite of the book Pro SQL Server Internals by Dmitri Korotkevitch that ansers your question:

In a nutshell, each temporal table consists of two tables — the current table with the current data, and a history table that stores old versions of the rows. Every time you modify or delete data in the current table, SQL Server adds an original version of those rows to the history table.

A current table should always have a primary key defined. Moreover, both current and history tables should have two datetime2 columns, called period columns, that indicate the lifetime of the row. SQL Server populates these columns automatically based on transaction start time when the new versions of the rows were created. When a row has been modified several times in one transaction, SQL Server does not preserve uncommitted intermediary row versions in the history table.

SQL Server places the history tables in a default filegroup, creating non-unique clustered indexes on the two datetime2 columns that control row lifetime. It does not create any other indexes on the table.

In both the Enterprise and Developer Editions, history tables use page compression by default.

So it's not

reference/links to the original values of the master table

Previous row version is just copied as it is into historical table on every mofification.



来源:https://stackoverflow.com/questions/48700772/sql-server-temporal-table-storage-costs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!