欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

where 子句的執(zhí)行順序

 更新時間:2009年04月05日 00:35:02   作者:  
貌似在2005之前的版本中,where子句的順序是從前往后的。但是又貌似在2005的版本中進行了優(yōu)化,所有的順序都被統(tǒng)一成了以過濾能力進行排序的語句。
看代碼:
復(fù)制代碼 代碼如下:

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語句的各個條件的查詢順序
環(huán)境:SQLServer 2005Express版本
步驟:顯示查詢計劃
結(jié)果:無一例外,都被統(tǒng)一成了這樣的代碼
復(fù)制代碼 代碼如下:

|--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')))

結(jié)論:貌似在2005之前的版本中,where子句的順序是從前往后的。但是又貌似在2005的版本中進行了優(yōu)化,所有的順序都被統(tǒng)一成了以過濾能力進行排序的語句。

相關(guān)文章

最新評論