Difference Between Insert and Update / Update and Insert

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
DeepakCorning
Premium Member
Premium Member
Posts: 503
Joined: Wed Jun 29, 2005 8:14 am

Difference Between Insert and Update / Update and Insert

Post by DeepakCorning »

In my target DRS I see two options - Insert or Update and Update or Insert. Whts the difference between these two? I thought they do the same thing till I see it in my database the rows are getting duplicate if I use Insert or Update.

The other option is very slow . Please suggest.
Thanks
Deepak Patil

Convince Them Confuse Them .. What's the difference?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The difference should be pretty apparent from thier names - it is the order the actions are taken. In either case, the first action must fail for the second to fire, so you typically choose which to use based on which of the operations you'll have the majority of.

Unique keys can be critical to how well it works. For example, the only reason for an insert to fail should be that there is already a record with that unique key in the table so the insert fails and the update is performed. When update comes first, that 'fails' when it can't find the record to update and when that happens it tries to insert it. Like any update, that check can be slow without indexes to support it as each turns into a full table scan.

Me, I never use them, preferring instead to explicitly classify inserts versus updates and dedicate links to each.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DeepakCorning
Premium Member
Premium Member
Posts: 503
Joined: Wed Jun 29, 2005 8:14 am

Post by DeepakCorning »

chulett wrote: the first action must fail for the second to fire, so you typically choose whi ...

Got it... Thats wht I was missing.... First Action Fail.. I had not contraints/inique keys in my table. Will test it now...
Thanks
Deepak Patil

Convince Them Confuse Them .. What's the difference?
Post Reply