计算值列是否锁定整个表并重新更新为新值?
我正在研究为 SQL Server 2008 创建一个 MD5 校验和持久计算值。这个特定表中有 GB 的数据(不是我的设计),我想知道如果我创建新的计算列,这是否会锁定整个表,直到计算完成了吗?
新列是否会更新表中的所有条目,还是仅在通过 SQL 命令选择/更新它们时才更新它们?
在 SQL Server 中创建 MD5 计算值的建议做法是什么?
I am looking into created an MD5 checksum persisted computed value for SQL Server 2008. There is gigabytes of data in this particular table(not my design) and I would like to know if I create the new computed column will this lock the entire table until the computation has finished?
Will the new column update all entries in the table or update them only when they are selected/updated via a SQL command?
What is the recommended practice for created MD5 computed values in SQL Server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在虚拟机上启动数据库的精确副本后,我尝试添加持久列。
大约有 100 万行,计算 MD5 哈希列花了 2 个小时。此时整个表都被锁定以进行选择、更新和插入。在生产服务器上,您必须考虑其他问题。
After kicking up an exact copy of the database on a virtual machine I experimented with adding the persisted column.
There were about 1 million rows and it took 2 hours to compute the MD5 hash column. In this time the entire table was locked for select, update and insert. On a production server you would have to factor in other issues.
添加未持久化的新计算列仍会锁定表,但速度非常快。
然后更改要持久化的列很慢,但似乎不会锁定表。
青年MMV
Adding a new computed column that isn't persisted still locks the table but is very fast.
Then altering the column to be persisted is slow but doesn't appear to lock the table.
YMMV