Redian新闻
>
SQL Server Question: how delete works
avatar
SQL Server Question: how delete works# Database - 数据库
f*e
1
Very simple question: when delete a record in SQL server, what are the locks
applied? My understanding is IX -> X. I am not sure if there is S lock
applied before IX. In another word, when delete a record, to reduce chance
of deadlock and improve performance, should I check if the record exists
first? Or should I call delete command directly and check if the affected
rows is 0?
avatar
j*n
2
use EXISTS and WITH (NOLOCK) hint for your checking step would be a good
practice.

locks

【在 f*****e 的大作中提到】
: Very simple question: when delete a record in SQL server, what are the locks
: applied? My understanding is IX -> X. I am not sure if there is S lock
: applied before IX. In another word, when delete a record, to reduce chance
: of deadlock and improve performance, should I check if the record exists
: first? Or should I call delete command directly and check if the affected
: rows is 0?

avatar
c*y
3
lS 正解
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。