2

将数据插入表时,我想在 sql server 中使用 ROWLOCK 选项。它是否有任何帮助。它会帮助我减少数据库中的阻塞吗?

4

1 回答 1

2

Using ROWLOCK is a hint to the SQL Server query optimizer that you know better than it does about this SQL query. It basically says lock the table/view rows affected by the FROM clause of your query rather than escalating to a page or table lock.

If applied by an experienced developer or administrator, it might help with blocking in very specific circumstances. But in general I would leave the locking strategy up to the query optimizer unless you've clearly identified that locking isn't being done efficiently for a specific query.

There is a good article on lock escalation for SQL Server 2005, though I believe there have been some changes in SQL Server 2008. There is a decent article on locking in SQL Server 2008.

于 2012-12-19T10:45:08.347 回答