I am using plain JDBC (because JPA was too slow for me) to implement a job which will run daily:
- Set Auto-Commit False
- TRUNCATE TARGET TBL (This is required to delete data from previous day)
- LOOP - SELECT FROM Servr1.DB.SRC in batches of 5000
- INSERT BATCH OF 5000 TO Servr2.DB.SRCTarget
- Continue Loop Or Goto #6
- Connection.commit
This works for me but has a couple of issues-
a. The load is still slow as it is taking 20mins to load a million. For 10M I am estimating that it will go upto 3hrs. Can this be reduced?
b. When I do a SELECT COUNT (from a SQL Client) while the job is running, both the SELECT and the INSERTs (in the job) get blocked and I have to reboot the server where the Java code is deployed to release the locks. Can this be prevented ?
Note: The isolation level set on the Target DB is - read committed