双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

(急)两段sql查询语句性能的比较和sql执行计划中的“表假脱机”?

zxjocy zxjocy 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
1、sql执行计划中的“表假脱机”是什么意思?执行机制是怎么样的?
2、两段sql查询语句执行后的目的是一样的,两条语句都没有错,
问题是 这两条语句的性能差别在哪?原因是什么?

--语句1:
select top 1 A.UserId,A.Phone,B.CodeId,Cmd,Addr,key1,key2,RContent,B.FeeMode from dbo.[V_AddFeePhoneUser] A WITH(NOLOCK),
(
select A.AreaId,A.FeeMode,A.OperatorsType,A.CodeId,Cmd,Addr,key1,key2,RContent from dbo.V_AreaToFeeCode_FeeCodeInfo A WITH(NOLOCK),
(
select AreaId,OperatorsType from dbo.UserInfo WITH(NOLOCK)
where AreaId>0 and Phone!='' and IMSI!='' and MonthSumFee<800 and addflag=0 and AvailFlag=1 group by AreaId,OperatorsType having COUNT(AreaId)>10
) C ,
dbo.V_GetUsableMaxCode B WITH(NOLOCK)
where A.FeeMode=11 and A.AreaId=C.AreaId and A.OperatorsType=C.OperatorsType and A.CodeId=B.CodeID
) B
where A.AreaId=B.AreaId and A.OperatorsType=B.OperatorsType
and
0.00005 >= CAST(CHECKSUM(NEWID(), UserId) & 0x7fffffff AS float)/ CAST (0x7fffffff AS int)
order by UserId

--和下面语句对比
--语句2:
select top 1 A.UserId,A.Phone,B.CodeId,Cmd,Addr,key1,key2,RContent,B.FeeMode from dbo.[V_AddFeePhoneUser] A WITH(NOLOCK),
(
select A.AreaId,A.FeeMode,A.OperatorsType,A.CodeId,Cmd,Addr,key1,key2,RContent from dbo.V_AreaToFeeCode_FeeCodeInfo A WITH(NOLOCK),
(
select AreaId,OperatorsType from dbo.UserInfo WITH(NOLOCK)
where AreaId>0 and Phone!='' and IMSI!='' and MonthSumFee<800 and addflag=0 and AvailFlag=1 group by AreaId,OperatorsType having COUNT(AreaId)>10
) C ,
dbo.V_GetUsableMaxCode B WITH(NOLOCK)
where A.FeeMode=11 and A.AreaId=C.AreaId and A.OperatorsType=C.OperatorsType and A.CodeId=B.CodeID
) B
where A.AreaId=B.AreaId and A.OperatorsType=B.OperatorsType
and
0.00005 >= CAST(CHECKSUM(NEWID(), UserId) & 0x7fffffff AS float)/ CAST (0x7fffffff AS int)
--两个的性能差别在哪?原因是什么?


我在这守着,看看有没有人来。
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
zxjocy
C# 111,129 成员 642,540 内容