Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317884

Summary: EclipseLink ignores QueryHints.JDBC_FETCH_SIZE
Product: z_Archived Reporter: Mike Seminaro <michael.seminaro>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: eclipselink.orm-inbox, gordon.yorke
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch none

Description Mike Seminaro CLA 2010-06-24 17:32:50 EDT
Please note observations obtained by experiments below:

Observation 1, query all contacts using JPA

           long startTime = System.currentTimeMillis();
           Query query = em.createQuery("SELECT c FROM Contact c");
           query.setHint(QueryHints.QUERY_REDIRECTOR, new IgnoreDefaultRedirector());
           //query.setHint(QueryHints.JDBC_FETCH_SIZE, 500);

           List<Contact> contacts = (List<Contact>)query.getResultList();

           for(Contact c : contacts)
           {
           }
           System.out.println("Execute query took " + (System.currentTimeMillis() - startTime) + " ms");
           System.out.println("contacts.size()="+contacts.size());

Output:
Execute query took 31362 ms
contacts.size()=205

Observation 2, query all contacts using JDBC

-- Code sample omitted to improve readability --

Output:
Execute query took 222 ms
Full logic took 10735 ms

Observation 3, query all contacts using JPA - uncommented query.setHint(QueryHints.JDBC_FETCH_SIZE, 500);

Output:
Execute query took 26454 ms
contacts.size()=205

Observation 4, query all contacts using JDBC - uncommented s.setFetchSize(500);

Output:
Execute query took 459 ms
Full logic took 592 ms

Conclusion:

- JDBC responded well to fetch size setting, execution time went down from 10735 ms to 592 ms (an 18x improvement)

- On the other hand, EclipseLink JPA did not respond as well to QueryHints.JDBC_FETCH_SIZE 31362 ms vs. 26454 ms. The difference is not as significant and can probably be eliminated if we use the average by repeating this experiment by a sufficient number of times.

Is EclipseLink ignoring QueryHints.JDBC_FETCH_SIZE? It seems like the value is never set on the JDBC statement that is being executed within EL (I used the debugger to verify this).
Comment 1 Gordon Yorke CLA 2010-06-29 15:27:25 EDT
EclipseLink only applies JDBC_FETCH_SIZE when
Comment 2 Peter Krogh CLA 2010-07-27 10:05:04 EDT
Created attachment 175317 [details]
Patch
Comment 3 Peter Krogh CLA 2010-07-27 13:28:37 EDT
Fixed Checked into 2.1.1 and trunk.  Reviewed by Gordon.
Comment 4 Peter Krogh CLA 2010-07-27 13:31:48 EDT
Closing
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:27:57 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink