I want your help in order to improve in time the following procedure in Java. The procedure steps are the following:
- I have a table with more than a million records (primary key is auto increment).
- I select the min and max primary key value from this table.
- I create some initial 'fromRange' and 'toRange' variables based on the min and max values
After I create a loop where I process 20000 records each time:
I fetch the records between 'fromRange' up to 'toRange'
For each record return, I write (append each time) to an XML object (using JAXB)
After I write the XML object created on a file on a disk.
Increase the 'fromRange' and 'toRange' to continue to the next records.
Procedure ends after all records have been process.
This execution takes more than 12 Hours on a normal PC to finish. I was wondering how can I improve this code to export the files faster. Maybe using threading?
Thanks