看代码:
复制代码 代码如下:
set statistics io on
set statistics time on
go
set statistics profile on
go
use pubs
select * from authors
where (au_fname like 'S%' or au_fname like 'a%')
and (state like 'CA' or state like 'UT')
and (cast(zip as int) > 90000)
select * from authors
where (au_fname like 'S%' or au_fname like 'a%')
and (cast(zip as int) > 90000)
and (state like 'CA' or state like 'UT')
select * from authors
where (cast(zip as int) > 90000)
and (au_fname like 'S%' or au_fname like 'a%')
and (state like 'CA' or state like 'UT')
目的:想验证where语句的各个条件的查询顺序
环境:SQLServer 2005Express版本
步骤:显示查询计划
结果:无一例外,都被统一成了这样的代码
复制代码 代码如下:
|--Clustered Index Scan(OBJECT:([pubs].[dbo].[authors].[UPKCL_auidind]), WHERE:(CONVERT(int,[pubs].[dbo].[authors].[zip],0)>(90000) AND ([pubs].[dbo].[authors].[au_fname] like 'S%' OR [pubs].[dbo].[authors].[au_fname] like 'a%') AND ([pubs].[dbo].[authors].[state] like 'CA' OR [pubs].[dbo].[authors].[state] like 'UT')))
结论:貌似在2005之前的版本中,where子句的顺序是从前往后的。但是又貌似在2005的版本中进行了优化,所有的顺序都被统一成了以过滤能力进行排序的语句。
复制代码 代码如下:
set statistics io on
set statistics time on
go
set statistics profile on
go
use pubs
select * from authors
where (au_fname like 'S%' or au_fname like 'a%')
and (state like 'CA' or state like 'UT')
and (cast(zip as int) > 90000)
select * from authors
where (au_fname like 'S%' or au_fname like 'a%')
and (cast(zip as int) > 90000)
and (state like 'CA' or state like 'UT')
select * from authors
where (cast(zip as int) > 90000)
and (au_fname like 'S%' or au_fname like 'a%')
and (state like 'CA' or state like 'UT')
目的:想验证where语句的各个条件的查询顺序
环境:SQLServer 2005Express版本
步骤:显示查询计划
结果:无一例外,都被统一成了这样的代码
复制代码 代码如下:
|--Clustered Index Scan(OBJECT:([pubs].[dbo].[authors].[UPKCL_auidind]), WHERE:(CONVERT(int,[pubs].[dbo].[authors].[zip],0)>(90000) AND ([pubs].[dbo].[authors].[au_fname] like 'S%' OR [pubs].[dbo].[authors].[au_fname] like 'a%') AND ([pubs].[dbo].[authors].[state] like 'CA' OR [pubs].[dbo].[authors].[state] like 'UT')))
结论:貌似在2005之前的版本中,where子句的顺序是从前往后的。但是又貌似在2005的版本中进行了优化,所有的顺序都被统一成了以过滤能力进行排序的语句。
标签:
where,子句,执行顺序
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
岱庙资源网 Copyright www.zgmyg.com
暂无“where 子句的执行顺序”评论...
更新日志
2024年04月29日
2024年04月29日
- dnf登录黑屏时间太久无响应
- 很明显喷人比浇花更快乐 动图 妖精的身份被你发现了
- 电路规划+牌组构筑!《末日电涌》即将于5.10发售!
- 才刚经历过大更新的星露谷物语,怎么就惹到国内玩家了?
- 【爵士沙发】VA-2024-BarLoungeCostesVol.8(FLAC)
- 【布鲁斯摇滚】DavidePannozzo-2024-RoomforJoy(FLAC)
- 伊能静.1995-下大雨了春花开了【飞碟】【WAV+CUE】
- CCTV6影评:剧场版《间谍过家家》笑点密集治愈拉满
- 麦当劳退款原因写顾客是傻X引争议:高管出面致歉
- 前战神主创谈剑星和谐争议:若是索尼干的就太耻辱了
- 西卿.1997-西北风(布袋戏精选)【金瓜石】【WAV+CUE】
- 王俪婷.2013-等等【华研国际】【WAV+CUE】
- 徐小凤.1981-新曲与精选1+2【SONY】【WAV+CUE】
- 圣遗物怎么获得?原神新手圣遗物获取方法
- 崩铁大电影官宣一览,4.8版本活动出场