A while ago I had a database performance problem for inserting/updating several million records using jdbc
. To increase performance I changed the code to use batch
. Then I decided to monitor the code using jprofiler
to know how much the performance is increased ... but meanwhile the monitoring I found an odd thing!
As you can see from the above screenshot, generating new id from a sequence is very slow. The screenshot is so descriptive just I must say the second row is an inner join
query on a table with ~8 milion records with itself and some computations (compare its time with the time of third query!).
I asked the problem from our dba and he said something about oracle recommendation for caching sequences but when I checked the sequence I saw it's already cached.
CREATE SEQUENCE "XXXXXXXXXXXX_ID_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE;
Any thought?
p.s. I think Hibenate
uses sequences for inserting records similarly, and actually I'm looking for best practices to use sequences to improve the performance of our project that uses hibernate. The above jdbc task is terminated.