You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/introduction/Tuning.adoc
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,30 @@ In a container environment, you usually don't need to configure a connection poo
101
101
Instead, you'll use a container-managed datasource, as we saw in <<basic-configuration-settings>>.
102
102
****
103
103
104
+
A related important setting is the default JDBC fetch size.
105
+
106
+
[[jdbc-fetch-size]]
107
+
=== JDBC fetch size
108
+
109
+
The _JDBC fetch size_ controls the maximum number of rows the JDBC driver fetches from the database in one round trip.
110
+
In Hibernate we usually limit query result sets using <<pagination,pagination>>, and so we almost always prefer that the JDBC driver fetch the whole query result set in one trip.
111
+
Most JDBC drivers accommodate this usage pattern by _not_ setting a default fetch size.
112
+
However, there are a couple of exceptions to this and for the offending drivers you should probably override the default fetch size using the following configuration property.
113
+
114
+
.Default JDBC fetch size
115
+
[%breakable,cols="37,~"]
116
+
|===
117
+
| link:{doc-javadoc-url}/org/hibernate/cfg/JdbcSettings.html#STATEMENT_FETCH_SIZE[`hibernate.jdbc.fetch_size`] | The default JDBC fetch size
118
+
|===
119
+
120
+
The default fetch size can be overridden for a given query by calling link:{doc-javadoc-url}/org/hibernate/query/SelectionQuery.html#setFetchSize(int)[`setFetchSize()`], but this is rarely necessary.
121
+
122
+
[WARNING]
123
+
====
124
+
The Oracle JDBC driver defaults to a JDBC fetch size of 10.
125
+
You should _always_ set explicitly `hibernate.jdbc.fetch_size` if you're using Oracle.
0 commit comments