Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.1
-
None
Description
I noticed that executing groovy.sql.Sql.firstRow passes a maxRows parameter with value 1 to groovy.sql.Sql.eachRow. The maxRows value, however, is only used to limit ResultSet iteration.
I believe JDBC drivers can optimize the data that is actually retrieved if the maxRows is set on the Statement prior to executing the SQL. If maxRows is not set, the driver may prefetch more results than is necessary and the database may end up doing more work.
See http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#setMaxRows(int)