Performance Issue - Constant Delay in ResultSet.next()
843854Nov 16 2003 — edited Dec 23 2004Hi,
My application server and database server are on different machines.
I executed a query which resulted in few thousands of rows.
Then, I would loop through the resultset and set it to my object
(code snippet as below):
while (resultset.next()) {
// print some log info - (1)
// create my object - (2)
// set resultset to object - (3)
}
I noticed that before entering the loop for the first time, there would
be a delay for about 10 seconds. And this would re-occur constantly after processing about 500 records. Meaning to process 4000 records,
the minimum time needed is 10 x (4000 / 500) = 80 seconds.
I tried executing the same query with a database client program. I tooks
less than 10 seconds to return all the rows to me.
1) Could someone please explain what is the ~10 seconds delay for with
the JDBC query ?
2) Is there anyway to improve the performance for the query ? The
database client program needed only 1/8 of the time to give me all
the rows.
(I tried setting the fetchsize but my JDBC driver don't seem
to bother)
Please advice.
Thank you.