_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › BetweenJoinHashJoin朱
|
|
between join 覃 loop join . hash join朱 覦蠖 螻 襭螳 覓殊企 襴企慨. れ螻 螳 企 .
drop table #temp_seg create table #temp_seg ( seg_nm varchar(50), bdt date, edt date ) insert into #temp_seg values ( '01_8~16', '2012-08-01', '2012-08-16') insert into #temp_seg values ( '02_8~15', '2012-08-03', '2012-08-15') insert into #temp_seg values ( '03_7~31', '2012-07-01', '2012-07-31') ;with dummy as ( select convert(datetime, '20120701') dt union all select dt + 1 from dummy where dt + 1 < '20120816' ) select dt into #dt from dummy option (maxrecursion 0); れ螻 螳 覃 hash join . loop join 覦 . 覃 '=' 一一螳 蠍 覓語企.
select * from #temp_seg a inner hash join #dt b on b.dt between a.bdt and a.edt /* 覃讌 8622, 譴 16, 1, 譴 1 貎朱Μ 碁 誤 貎朱Μ 襦語 貎朱Μ 螻 燕 給. 碁ゼ 讌蟇磯 SET FORCEPLAN 讌 螻 貎朱Μ襯 れ ″. */ hash join 覦 '=' join 伎 覩襦 螳襦 '=' 襷れ 譴. 襯 伎覃 牛磯伎螳 蟆 蠍 覓語 . れ螻 螳 牛磯伎襯 碁.
select * from #temp_seg a inner hash join #dt b on b.dt between a.bdt and a.edt and datalength(checksum(a.bdt)) = datalength(checksum(b.dt))企蟆 hash join . checksum() 襷り覲襦 企 覓語企 覦れ企, 伎襦 int 螳 襴危. datalength() 襷り覲 一危 蠍(byte)襯 襴危. 蠏碁覩襦 sql 覲企 int byte4螳 襴願企. 讀, datalength(checksum(a.bdt)) = datalength(checksum(b.dt)) = 4.
鏤
|
蠖 蠍磯ゼ 滑 蠍磯 蠍壱襯 葛. |