By setting the sample size, you OutOfMemoryError risk of OutOfMemoryError .
The fact that you need all of these notes in any case is probably not justified. More likely that you need entities reflected by the returned ResultSet s ... Setting the sample size to 10000 means that you are typing 10,000 records represented by JDBC classes. Of course, you do not go through this through your application. First, you transform them into your favorite business logical entities, and then pass them to your business executor logic. Thus, the records forming the first sample array are available to the GC as soon as JDBC retrieves the next sample size.
Typically, this conversion is performed with a small number of bits at a time precisely because of the memory threat mentioned above.
One thing you are absolutely right: you must test performance with clearly defined requirements before tuning.
source share