eclipselink.jdbc.fetch-size to specify the number of rows to be fetched from the database when additional rows are needed.
This property requires JDBC driver support.
Table 4-15 describes this query hint's valid values.
Table 4-15 Valid Values for eclipselink.jdbc.fetch-size
If 0, the JDBC driver default will be used.
For queries that return a large number of objects, you can configure the row fetch size used in the query to improve performance by reducing the number database hits required to satisfy the selection criteria.
By default, most JDBC drivers use a fetch size of 10. , so if you are reading 1000 objects, increasing the fetch size to 256 can significantly reduce the time required to fetch the query's results. The optimal fetch size is not always obvious. Usually, a fetch size of one half or one quarter of the total expected result size is optimal.
If you are unsure of the result set size, incorrectly setting a fetch size too large or too small can decrease performance.
Example 4-32 shows how to use this hint in a JPA query.
Example 4-32 Using jdbc.fetch-size in a JPA Query
import org.eclipse.persistence.config.HintValues; import org.eclipse.persistence.config.QueryHints; query.setHint("eclipselink.JDBC_FETCH_SIZE", "100");
Example 4-33 shows how to use this hint with the
Example 4-33 Using jdbc.fetch-size in a @QueryHint Annotation
import org.eclipse.persistence.config.HintValues; import org.eclipse.persistence.config.QueryHints; @QueryHint(name=QueryHints.JDBC_FETCH_SIZE, value="100");
For more information, see:
"Querying" and "Enhancing Performance" in Solutions Guide for Oracle TopLink
"Oracle TopLink Caches" in Understanding Oracle TopLink