首先是看Java JDBC的API查看setFetchSize:
setFetchSize(int rows)
Givesthe JDBC driver a hint as to the number of rows that should be fetched from thedatabase when more rows are needed for this ResultSetobject.
查看的结果给出这里的rows只是一个hint,那么对于MySQL JDBC来说是如何实现的呢?
There is experimental support for fetching rows in batches
When using Connector/J 5.0.1 along with more recent builds of the MySQL server, you can add "useCursorFetch=true" to your JDBC url parameters, and the driver will fetch rows in batches of size setFetchSize() as defined in the JDBC API.
One could also argue that the behavior _does_ follow the JDBC API, quoting from the APIDOCS for Statement.setFetchSize():
"Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified affects only result sets created using this statement.