Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] fetch size setting without effect

James,

that was it, thank you for the hint. But what's it with the distinct state setting at nested queries?

Thomas



----- Original Message ----
From: James Sutherland <jamesssss@xxxxxxxxx>
To: eclipselink-users@xxxxxxxxxxx
Sent: Monday, October 20, 2008 3:57:40 PM
Subject: Re: [eclipselink-users] fetch size setting without effect


I think the issue is the nested query is already prepared, so you need to set
the fetch size into the call, instead of the query.

q.getCall().setResultSetFetchSize(5000);


Thomas Paradies-2 wrote:
> 
> Hi,
> 
> it seems that fetch size setting at an embedded batch query wouldn't have
> the expected effect.
> 
> To demonstrate the issue I've constructed a very simple szenario with two
> entities A and B with an One(A)ToMany(B) relationship between them. 
> 
> @Entity @Table(name = "T0")
> public class A {
>     @Id @Column(name = "A_ID")
>     private long id;
>    
>     @OneToMany(mappedBy = "a")
>     private List bs;
>    
>     public List getBs() { return bs; }
> }
> 
> @Entity @Table(name = "T1")
> public class B {
>     @Id @Column(name = "B_ID")
>     private long id;
> 
>     @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "A_ID")
>     private A a;
>    
>     public A getA() { return a; }
> }
> 
> The code fragment below shows two findAll methods - one should retrieve
> all As and as result all related Bs and the other should get all Bs with
> all related As (but just lazy).
> ....  
>     public List  findAllAs() {
>         ReadAllQuery query = new ReadAllQuery(A.class);
>         query.setFetchSize(500);
>         query.addBatchReadAttribute(builder.get("bs"));
>         query.prepareCall(getServerSession(), null);
>         Map map = query.getBatchReadMappingQueries();
>         if (map != null) {
>             for (Object key : map.keySet()) {
>                 if (key.equals("bs")) {
>                     ReadAllQuery q = (ReadAllQuery) map.get(key);
>                     q.setFetchSize(5000);
>                 }
>             }
>         }
>         List  as = (List ) getServerSession().executeQuery(query);
>         return as;
>     }
> 
>     public List findAllBsForAs() {
>         ReadAllQuery query = new ReadAllQuery(B.class);
>         query.setFetchSize(5000);
>         query.prepareCall(getServerSession(), null);
>         List bs = (List) getServerSession().executeQuery(query);
>         return bs;
>     }
> ....
> 
> With the profiling done for each of the methods using PerformanceProfiler
> and EclipseLink log I got the following outputs (for clarification only
> the relevant parts are shown)
> 
> - for findAllAs() the profiler output for embedded batch query
> ....
> Begin profile of{ReadAllQuery(com.mons.entity.B)
> [EL Fine]: 2008.10.17 09:46:59.422--Connection(26188661)--SELECT t0.B_ID
> FROM T0 t0, T1 t1 WHERE (t0.A_ID = t1.A_ID)
> Profile(ReadAllQuery,
>     class=com.mons.entity.B,
>     number of objects=4721,
>     total time=33733,
>     local time=33733,
>     profiling time=16,
>     row fetch=33139,
>     object building=267,
>     cache=111,
>     logging=32,
>     sql execute=265,
>     time/object=7,
>     objects/second=139,
> )
> }End profile
> ....
> 
> - for findAllBsForAs() the profiler output for main query
> ....
> Begin profile of{ReadAllQuery(com.mons.entity.B)
> [EL Fine]: 2008.10.17 09:49:33.102--Connection(19351067)--SELECT t0.B_ID
> FROM T0 t0, T1 t1 WHERE  (t1.A_ID = t0.A_ID))
> Profile(ReadAllQuery,
>     class=com.mons.entity.B,
>     number of objects=4721,
>     total time=1530,
>     local time=1530,
>     cache=173,
>     sql prepare=172,
>     row fetch=63,
>     sql execute=921,
>     object building=343,
>     logging=31,
>     objects/second=3085,
> )
> ....
> 
> The query string for findAllAs() equals the query string of
> findAllBsForAs() and the fetch size setting is even for both of them.
> Nevertheless the "row fetch" value in the profile of the batch query is
> 33139 (near 33733 for "total time" so I'm assuming the unit is ms) but
> only 63 (1530 total) for the direct query. With an fetch size of 5000 for
> 4721 retrieved objects the second value but not the first is as I would
> expecting...
> 
> My question is: Am i doing something wrong, am I missing something, or
> maybe this is a bug?
> 
> I'm grateful for any idea or suggestion, 
> 
> Thomas
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/fetch-size-setting-without-effect-tp20032090p20067740.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



Back to the top