on 2014 Aug 13 6:12 AM
Two tables:
A (col1, col2, col3, primary key (col1, col2))
B (col1, col2, col3, col4, col5, primary key (col1, col2))
With table B having thousands of records, which of the following statements would be the least expensive?
Option 1:
insert into A (col1, col2, col3) on existing skip
select col1, col2, col3 from B
Option 2:
insert into A (col1,col2,col3)
select col1, col2, col3 from B
where not exists (select * from A where col1=b.col1 and col2=b.col2)
My gut tells me they're exactly the same. But I need more than my gut to go on.
Request clarification before answering.
Having said that, my guess is they will have the same plans and the same performance. I am VERY PROUD of my guesswork...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
30 | |
8 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.