使用只有一个定期更新的列的宽时间 table 是否有效?

Is using a wide temporal table with only one regularly updated column efficient?

我一直无法确定 table 历史记录的存储方式。 如果您有一个包含多列 nvarchar 数据和一个定期更新的库存数量列的 table,SQL 服务器是否为库存数量的每次更改存储静态列的副本,或者是否有一个面向对象存储数据的方法? 我想将所有列都包含在历史记录中,因为 nvarchar 列可能会有罕见的更改,但如果数百万个 qty 更新正在复制其他列,请注意 table 历史记录大小。

我建议您仅对需要监控的值使用 SQL 服务器临时 table 否则固定不变的属性值会随着每次更改而重复。 SQL 每当发生行更新时,服务器都会存储一个全新的行。 See the docs:

UPDATES: On an UPDATE, the system stores the previous value of the row in the history table and sets the value for the SysEndTime column to the begin time of the current transaction (in the UTC time zone) based on the system clock

您需要将固定的 varchar attributes/fields 移动到另一个 table 并使用关系,1:1 或任何 suitable.

同时查看 temporal-tables 标签下的其他相关问题:

SQL Server Temporal Table Creating Duplicate Records

Duplicates in temporal history table