0

我正在构建一个 VoIP 交换机,我将使用 SQL 存储过程进行插入。每次更新历史表时,我都需要更新用户表“余额字段”。由于它是一个开关,我每秒可以进行数百次更新。我想知道在没有死锁和错误信息的情况下更新字段的最佳方法。我将使用 MS sql server 2012。

4

1 回答 1

1

Partition the user table into evenly sized partitions - SQL 2012 allows 10000 of them. That way the updates are distributed over many allocation units instead of just one. Then add the WITH(ROWLOCK) hint to the update query.

To kick off the actual update you could use a trigger.

于 2012-10-19T22:59:08.697 回答