I have a question as to ordering table references in an Insert statement.
I have two tables--1) WELL_HDR, containing 1,500,000 rows.
2) LD_WELL_HDR containing about 50,000 rows.
Both tables have the same structure. The Primary Key is a column named UWI.
Both tables have a unique index on UWI.
I want to insert into WELL_HDR from LD_WELL_HDR all the unique rows.
My question is about the order of table names in my Insert sql.
INSERT INTO WELL_HDR
SELECT * FROM LD_WELL_HDR
WHERE NOT EXISTS
(SELECT UWI FROM WELL_HDR WHERE LD_WELL_HDR.UWI= WELL_HDR.UWI)
Does the smaller table (LD_WELL_HDR) or the larger table (WELL_HDR) come
first in the subquery? (Driver table?)
Any other suggestions for making this faster??
Also, I will be wanting to update the WELL_HDR table using some (but not all)
columns from the LD_WELL_HDR table. Hints on constructing the updates are