Skip to content

Commit f480369

Browse files
committed
discuss JDBC fetch size in Short Guide
Short Guide keeps getting longer
1 parent 453cc01 commit f480369

File tree

1 file changed

+24
-0
lines changed
  • documentation/src/main/asciidoc/introduction

1 file changed

+24
-0
lines changed

documentation/src/main/asciidoc/introduction/Tuning.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,30 @@ In a container environment, you usually don't need to configure a connection poo
101101
Instead, you'll use a container-managed datasource, as we saw in <<basic-configuration-settings>>.
102102
****
103103

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.
126+
====
127+
104128
[[statement-batching]]
105129
=== Enabling statement batching
106130

0 commit comments

Comments
 (0)