Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 improve performance

Author  Topic 

subhaoviya
Posting Yak Master

135 Posts

Posted - 2014-06-13 : 12:06:38
I have two large tables first table T1 having 41 million records and another table T2 having 20 million records.

T1:
C1
,C2
,C3....C10

T2:
C2,c11,c13,14...C20

table T2 having c2 as foreignkey reference. i am having index on c2 in t2.

query:
declare @start int,@end int, @cnt int
while(@start<@cnt)
begin
set @end=@start+1000
insert into T3
select c1,c2,c14 from t1 inner join t2 on(t1.c2=t2.c2) where
t1.c1>@start and t1.c1<=@end
set @start=@end
end

only 1 lakhs records gets inserted per min, is it any way to improve its performance?

Thanks
Subha


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-13 : 12:10:39
Show us the execution plan for one of the inserts. Also is T1.C2 indexed? How about T1.C1?

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -