Dear,

I use derby in my application.  There is no complicated technologies to be used, only 2- or 3-tiers architecture: derby+ibatis+J2EE/Java application. 
The Java application will run periodically some piece code every time. The time costs for that about several hours. 
Yes, there are over millions data in one table and computing in Java application is also intensive. 
What problem I have is, the application can run for the first time, but for the second time, it can not been completed because that derby will be very slow. 
I try to configure "xms512m xmx1024m" memory to start derby. It give the help but can still not solve the problem.
I guess it is related to the memory/page cash of derby. Maybe derby has not released the enough memory for new search?  
I want to only make clear what is the root cause of it and then we can make further decision.  Is it possible to select the data for a very long time because of the derby nature? Or it is sure that the bottleneck can be avoided?

                                                                             Sleven