UPDATE vs LEFT OUTER JOIN
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


UPDATE vs LEFT OUTER JOIN Expand / Collapse
Author
Message
Posted 11/14/2006 3:51:34 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 11/14/2006 10:03:00 PM
Posts: 1, Visits: 1
Hi All,

Wants your ideas on update vs Left Outer Join wrt Performance

I have 2 tables Table A and Table C in two databases.

Database 1:- Table_A (daily Full refresh)

Database 2: Table_A (Incremental Loading) and Table_C

So total 3 tables

table_A having col 1 , col 2 and col 3
table_C having col a , col b and col c

Currentlty I am doing

Step 1)

Update database1.table_A A, database2. table_C C
set A.col3 = C.col c
where A.col1 = C.col a and A.col2 = C.col b

after this

Step 2)

insert into database2.table_A
as select * from database1.table_A

But updates are taking really very longtime.. I am getting almost 10 Million records every day for database1.table_A and also very huge number records in database2.table_C as well (approx 40 million) . So step 1 taking much time.

So I am thinking of using following SQL to combine step 1 and stpe 2 and removing update

insert into database2.table_A
(
col 1,
col 2,
col 3
)
select
(A.col 1,
A.col 2,
C.col c
)
from database1.table_A A
LEFT OUTER JOIN database2.table_C C
ON A.col1 = C.col a and A.col2 = C.col b;

Is this OK? or any other ideas to improve performance?


Thanks,

Ajay

Post #5851
Posted 11/30/2006 4:12:51 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 8/7/2007 2:20:00 PM
Posts: 40, Visits: 1
The left-outrr join approach should be faster since you will avoid the transient logging that occurs for the update in step 1 of the original approach.


Make the PI of both table A and C the same as the joined columns (col1/cola, col2/colb) to keep the join amp local.

Also, it db2.tableA has the same PI, the insert into that table will laso be amp local.


 

Post #5968
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 9:04am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.016. 8 queries. Compression Disabled.