I have an application that moves data into a temp table to work it over and then moves data from the temp table into the actual production data.
Sometimes the data being imported already exists in the production table. Depending on the month, it could be just a few lines from the TEMP table, or it could be the entire temp table that already exists.
In order to move the data from the temp table, I use 2 SQLs:
1. Update Production table where key in (select keys from temp table)
After the existing data is updated, I can insert the new data:
2. Insert into production table from Temp Table where Temp Key not exists in (select keys from Production)
I don't know if this helps or not, but since the production tables are for reporting purposes, they are never purged (we must keep at least the previous 2 years of data). So production table keeps getting larger and larger. The data in the temp table could be any range from weeks to months.
The big question: Is my current method faster, or would it be faster to do:
1. Delete production table where key in (select keys from temp)
2. Insert into production from Temp
TIA for any assistance.
Sometimes the data being imported already exists in the production table. Depending on the month, it could be just a few lines from the TEMP table, or it could be the entire temp table that already exists.
In order to move the data from the temp table, I use 2 SQLs:
1. Update Production table where key in (select keys from temp table)
After the existing data is updated, I can insert the new data:
2. Insert into production table from Temp Table where Temp Key not exists in (select keys from Production)
I don't know if this helps or not, but since the production tables are for reporting purposes, they are never purged (we must keep at least the previous 2 years of data). So production table keeps getting larger and larger. The data in the temp table could be any range from weeks to months.
The big question: Is my current method faster, or would it be faster to do:
1. Delete production table where key in (select keys from temp)
2. Insert into production from Temp
TIA for any assistance.