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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Update With Join is Very Slow

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-30 : 08:34:08
Fawad writes "I have two tables with the following structure:

Transaction_Detail {PK(Tr_Id,SNo) Clustered} 6,00,000 Rows
Tr_ID int,
SNo smallint,
GSL_Code varchar(5),
Dr_Cr bit,
GSL_Running_Balance money,
GSL_Base_Running_Balance money

TempTable {PK(Tr_Id,SNo) Clustered} 5,40,000 Rows
Tr_ID int ,
SNo smallint,
GSL_Code varchar(5),
GSL_Running_Balance money,
GSL_Base_Running_Balance money

Primary key for the TempTable references Transaction_detail Primary Key. I would like to update columns GSL_Running_balance & GSL_Base_running_balance in the Transaction_Detail table with corresponding values in TempTable.

To do so i run the following statement :

UPDATE Transaction_Detail
SET GSl_Running_Balance = TT.GSl_Running_Balance,
GSl_Base_Running_Balance = tt.GSl_Base_Running_Balance
FROM TempTable TT
Join Transaction_Detail TD
ON Tt.Tr_ID = td.Tr_ID
AND Tt.SNo = td.SNo

This statement takes about 2 hours to finish. I am wondering as to how to make it work faster and what is it that i am missing.

Your help will be truly apperciated.

Regards."
   

- Advertisement -