Suppose I am a selecting 100k rows from a mysql table using following java code
Statement stmt=con.createStatement(); stmt.setFetchSize(FETCH_SIZE); ResultSet rs=stmt.executeQuery(sqlSelectQuery);
then does it means
- MySQL server take the entire result of select at once in its memory, and FETCH_SIZE rows to JVM heap, and transfer data from result stored at mysql server memory to JVM heap or
- MySQL server take FETCH_SIZE rows of query at once in its memory, and at each network round trip, server querying the rows and transfer all data to JVM heap.