hibernate抓取效率问题
在csdn上面看到的……
--drop table #t1,#t2
create table #t1(userid int not null)
create table #t2(userid int not null)
declare @i int,@1 INT,@2 INT ,@3 INT
SELECT @1= 90000 ,@2= 80000,@3= 100000
set @i = 1
while @i <= @1
begin
insert into #t1(userid) values(@i)
set @i= @i + 1
end
set @i = @2
while @i <= @3
begin
insert into #t2(userid) values(@i)
set @i= @i + 1
end
declare @time datetime,@show varchar(8000)
set @time = getdate()
select *
from #t1 a inner join #t2 b
on a.userid=b.userid
set @show = 'inner join: ' + cast(datediff(ms,@time,getdate()) as varchar)
set @time = getdate()
print @show
select *
from #t1 a left join #t2 b
on a.userid=b.userid
set @show = 'left join: ' + cast(datediff(ms,@time,getdate()) as varchar)
set @time = getdate()
print @show
-----------------
A有B没有 都有 A没有B有 A表数据 B表数据 INNER LEFT
80% 10% 10% 1~90000 80000~100000 483 1596
33% 33% 33% 1~60000 30000~90000 873 1280
10% 80% 10% 1~90000 20000~100000 1610 1826
45% 10% 45% 1~55000 45000~100000 516 1140
10% 80% 10% 1~90000 20000~100000 1733 1923
10% 10% 80% 1~20000 10000~100000 453 610
昨天的第二个实验应该属于这里的最后一种情况,这里测了多次,取了个平均值