Hello
I got a little question about performance of a subquery / joining another table
INSERT
INTO Original.Person
(
PID, Name, Surname, SID
)
(
SELECT ma.PID_new , TBL.Name , ma.Surname, TBL.SID
FROM Copy.Person TBL , original.MATabelle MA
WHERE TBL.PID = p_PID_old
AND TBL.PID = MA.PID_old
);
This is my SQL, now this thing runs around 1 million times or more.
Now my question is what would be faster?
if I change TBL.SID
to (Select new from helptable where old = tbl.sid)
or if I add helptable to the from and do the joining in the where?
edit1
well this script runs only as much as there r persons.
my program have 2 moduls one that populates MaTabelle and one that Transfers Data.
this program does merge 2 database together and coze of this, sometimes the same Key is uesd.
Now im working on a solution that no dublicated Keys existing.
My solution is to make a HelpTable. The owner of the key(SID
) generates a new key and writes it into a help table. All other Tables who uses this key can read it from the help Table
edit2
just got something in my mind:
if a table as a Key that can be null(foreignkey that is not linked)
then this wont work with the from or?
greets
Auro