- 論壇徽章:
- 0
|
回復(fù) #3 kanfu 的帖子
繼續(xù)更新條件測(cè)試:
SQL4:
select convert(varchar(20),getdate(),109)
SELECT count(*) FROM Item1 i1, Item2 i2
WHERE i1.code1 = i2.code1 and i1.code2 = i2.code2 and i1.code3 = i2.code3 and i1.code2 < '301'
select convert(varchar(20),getdate(),109)
go
SQL5:
select convert(varchar(20),getdate(),109)
SELECT count(*) FROM Item1 i1, Item2 i2
WHERE i1.code1 = i2.code1 and i1.code2 = i2.code2 and i1.code3 = i2.code3 and i1.code2 >= '301'
select convert(varchar(20),getdate(),109)
go
SQL6:
select convert(varchar(20),getdate(),109)
SELECT count(*) FROM Item1 i1, Item2 i2
WHERE i1.code1 = i2.code1 and i1.code2 = i2.code2 and i1.code3 = i2.code3 and i1.code2 > '102'
select convert(varchar(20),getdate(),109)
go
SQL7:
select convert(varchar(20),getdate(),109)
SELECT count(*) FROM Item1 i1, Item2 i2
WHERE i1.code1 = i2.code1 and i1.code2 = i2.code2 and i1.code3 = i2.code3 and i1.code2 <= '102'
select convert(varchar(20),getdate(),109)
go
結(jié)果集:
第4個(gè)SQL的執(zhí)行結(jié)果為:
Feb 4 2008 4:19:54
65309
Feb 4 2008 4:23:20
第5個(gè)SQL的執(zhí)行結(jié)果為:
Feb 4 2008 4:23:20
5832
Feb 4 2008 4:23:20
第6個(gè)SQL的執(zhí)行結(jié)果為:
Feb 4 2008 4:30:26
59387
Feb 4 2008 4:30:27
第7個(gè)SQL的執(zhí)行結(jié)果為:
Feb 4 2008 4:32:11
11754
Feb 4 2008 4:32:17
結(jié)果分析,用大于的查詢速度明顯要用小于的查詢速度快,Sybase的優(yōu)化出了什么問(wèn)題? |
|