Redian新闻
>
Question about SQL server lock
avatar
f*e
2
Say I have two tables, Employee and PayRate. Employee has a primary key
EmpID which is a foreign key to PayRate. I need to update any matched
employees whose pay rate is greater than 1. I have to consider both
performance and mutual lock. Here are two solutions:
1. SELECT then UPDATE
select @cnt=count(*) from employee where [email protected] and [email protected] and empid
in (select empid from payrate where rate >1)
if @cnt > 1
begin
update employee set status = 1 where [email protected] and [email protected] and empid in
(
avatar
h*n
3
我用过这个,一模一样,比起大缝纫机差远了。关键部位都是金属的,挺结实的,就是
缝东西时不好用。$16偏贵了,用一半的价钱就可以买到。
avatar
gy
4
下面两句我没看出啥区别来, 谁说说??
(一个先判断一下, 然后update, 另一个直接update.)

if @cnt > 1
begin
update employee set status = 1 where [email protected] and [email protected] and empid in
(select empid from payrate where rate > 1)
2. UPDATE directly
update employee set status = 1 where [email protected] and [email protected] and empid in
(select empid from payrate where rate > 1)

【在 f*****e 的大作中提到】
: Say I have two tables, Employee and PayRate. Employee has a primary key
: EmpID which is a foreign key to PayRate. I need to update any matched
: employees whose pay rate is greater than 1. I have to consider both
: performance and mutual lock. Here are two solutions:
: 1. SELECT then UPDATE
: select @cnt=count(*) from employee where [email protected] and [email protected] and empid
: in (select empid from payrate where rate >1)
: if @cnt > 1
: begin
: update employee set status = 1 where [email protected] and [email protected] and empid in

avatar
k*0
5
哦,这么便宜,哪里有?我再找找。
可以开贴讨论下最便宜好用的缝纫机了。
avatar
B*g
6
乱,看不懂。不看了,凑活用merge

in

【在 f*****e 的大作中提到】
: Say I have two tables, Employee and PayRate. Employee has a primary key
: EmpID which is a foreign key to PayRate. I need to update any matched
: employees whose pay rate is greater than 1. I have to consider both
: performance and mutual lock. Here are two solutions:
: 1. SELECT then UPDATE
: select @cnt=count(*) from employee where [email protected] and [email protected] and empid
: in (select empid from payrate where rate >1)
: if @cnt > 1
: begin
: update employee set status = 1 where [email protected] and [email protected] and empid in

avatar
h*n
7
我在walmart买的,很久以前的事了,现在walmart早就不卖了.论坛上有讨论缝纫机的帖
子,mm先找找看.
avatar
j*n
8
use IF EXISTS instead of count(*)

in

【在 f*****e 的大作中提到】
: Say I have two tables, Employee and PayRate. Employee has a primary key
: EmpID which is a foreign key to PayRate. I need to update any matched
: employees whose pay rate is greater than 1. I have to consider both
: performance and mutual lock. Here are two solutions:
: 1. SELECT then UPDATE
: select @cnt=count(*) from employee where [email protected] and [email protected] and empid
: in (select empid from payrate where rate >1)
: if @cnt > 1
: begin
: update employee set status = 1 where [email protected] and [email protected] and empid in

avatar
M*N
9
cute 好用吗?
avatar
z*y
10
The first solution actually duplicated in select statement.
To minimize the lock time or avoiding lock escalation, make sure you have
non clustered index on rate column in payrate table.
What would happen if you don't have non clustered index on rate column is
that query optimizer would upgrade to table level share lock if it think it
was more efficient than row level share lock. When table level share lock
was applied to table, it would exclude any update or insert operations onto
this table.

【在 f*****e 的大作中提到】
: Say I have two tables, Employee and PayRate. Employee has a primary key
: EmpID which is a foreign key to PayRate. I need to update any matched
: employees whose pay rate is greater than 1. I have to consider both
: performance and mutual lock. Here are two solutions:
: 1. SELECT then UPDATE
: select @cnt=count(*) from employee where [email protected] and [email protected] and empid
: in (select empid from payrate where rate >1)
: if @cnt > 1
: begin
: update employee set status = 1 where [email protected] and [email protected] and empid in

avatar
s*e
11
I did.Can only sew very small item, Better to have a bigger one
avatar
z*y
12
Actually in this senario, there are no difference. A friend Andy Lenard
wrote a CLR function to tell how it works internally, he found that sql
server will return true as soon as it found first matched record. In this
senario,
it would not fetch data before sending true or false.
Another way to verify this is from the execution plan.

【在 j*****n 的大作中提到】
: use IF EXISTS instead of count(*)
:
: in

avatar
r*g
13
这个要是拿来做沙发罩啥的估计不行,不过做小东西应该还好。我刚做了两个沙发罩,
用大缝纫机都觉得费劲。。

【在 k***0 的大作中提到】
: http://home.dillyeo.com/Product/Detail/7291
: 有人买过吗?好用吗?压脚等部位是金属还是塑料的?
: 总听说小缝纫机的部件是塑料的,用不住,怕买回来空欢喜一场。

avatar
i*t
14
我有个类似的,现在都没搞懂怎么用555
avatar
w*s
15
我有一个类似的,白色。关键部位都是金属。缝直线很好用,窗帘被罩围巾床单枕头都
缝过。也给衣服缝过内边。缝曲线需要点技巧。
买回来玩足够了。我一般每年用五六回吧。你要用的多可以考虑买个好一点的。

【在 k***0 的大作中提到】
: http://home.dillyeo.com/Product/Detail/7291
: 有人买过吗?好用吗?压脚等部位是金属还是塑料的?
: 总听说小缝纫机的部件是塑料的,用不住,怕买回来空欢喜一场。

avatar
w*s
16
忘了说了,我的有一个脚踏板。没有这个配件的话没法想象怎么用。

【在 w***s 的大作中提到】
: 我有一个类似的,白色。关键部位都是金属。缝直线很好用,窗帘被罩围巾床单枕头都
: 缝过。也给衣服缝过内边。缝曲线需要点技巧。
: 买回来玩足够了。我一般每年用五六回吧。你要用的多可以考虑买个好一点的。

avatar
F*x
17
蛮可爱的,不过这么小缝东西的时候会不会跑动啊。
avatar
m*o
18
买过,但是很不好用,最后还是退了买了个大的.主要感觉是不太STABLE,有的时候能缝得
好,有的时候震得厉害,线也很容易纠结在一起.
avatar
m*o
19
买过,但是很不好用,最后还是退了买了个大的.主要感觉是不太STABLE,有的时候能缝得
好,有的时候震得厉害,线也很容易纠结在一起.
avatar
c*n
20
非常不好用,国内曾经买过,走线不稳。加点钱到target有活动买个70多胜家的比这个
好。
avatar
s*g
21
不好,太小,走起来不稳
avatar
s*z
22
我用过类似的,简单的工作还行,没觉得有什么问题,不过我也就是把长了的裤子改改
小之类的,没有做过高级的,呵呵。
avatar
C*e
23
歪一下楼哈,
mm你做沙发罩都用什么布啊?哪儿买?

【在 r*****g 的大作中提到】
: 这个要是拿来做沙发罩啥的估计不行,不过做小东西应该还好。我刚做了两个沙发罩,
: 用大缝纫机都觉得费劲。。

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