Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How does the Oracle driver implement the Statement setMaxRows() JDBC method?

7e1df33b-8830-411a-967f-93e91044af7aSep 26 2015 — edited Sep 27 2015

According to the JDBC specifications, the Statement.setMaxRows(int maxRows) method is supposed to:

Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number. If the limit is exceeded, the excess rows are silently dropped.

When testing it against limiting the result set at the SQL level (e.g. ROWSET), both the JDBC and the SQL construct seem to perform very well.

Even when selecting millions of rows, the setMaxRows doesn't seem to perform worse.

Does the JDBC driver send any hint to the database server to optimize the plan for this specific result set size?

Does the Executor open a server-side cursor so the client can fetch records on demand, so when the maxRows threshold is reached, the database can close the cursor for good?

I suppose the database doesn't select the whole result set, only to send it over the wire so the client can simply discard the overflowing records.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2015
Added on Sep 26 2015
2 comments
1,924 views