I have been working on improving the performance (emphasis on execution speed) of a Java program that fetches records from a MySQL table. The reason for slowness is the large number of records the table is holding.
After some research, I had 2 options in hand-1. Batching and 2. Pagination.
- Batching
Batching was not attempted, since JavaDoc of addBatch says that typically it takes Update commands or insert commands.
- Pagination
It makes the process extremely slow because of the multiple calls to MySQL from Java.
Now, I am left out with the option of having a streaming result set for MySQL.
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);
My question is whether having a streaming result set improve the execution speed or will it reduce the speed of execution?
Note: I have gone through these discussions 1 and 2 Could you please enlighten. Thanks