cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin Skladaniec <>
Subject localObject vs prefetches: would there be a benefit ?
Date Fri, 02 Nov 2007 00:50:40 GMT

We are improving the performance of our client application (ROP). Not  
surprisingly we have found that adding prefetches did improve the  
speed significantly.

I have a question though about which is about efficiency of  
localObject. We are fetching a list of objects (query with prefetches)  
to a specific one non-editable context. If the object is to be edited  
it has to be copied to another context which allows committing  
changes. After the object is copied all the related object are  
accessed, so the performance of the copying came to my mind.

The test I have looks like this:

CayenneContext context1;
CayenneContext context2;

SelectQuery q = new SelectQuery(Painting.class);
q.addPrefetch(Painting. GALLERY_PROPERTY + "." + Gallery.CITY_PROPERTY);
List l = context1.performQuery(q);
//now the context1 contain all the records I wanted it to contain

Painting p1 = (Painting) l.get(0);
Painting p2 = (Painting) context2.localObject(p1.getObjectId(), null);

//now the context2 contain only the single record I copied
//now  context2 contains the same objects as context1

All is very quick, but my question is how it will scale when the  
relationship would be to-many and there will be hundreds related  

What do you think would be a threshold number of related objects which  
have to be localised over which it would be worth doing a new,  
specific select query for that single object (with prefetches). Would  
there be advantage of doing that at all ?

We are using cutting edge version of cayenne (I think we use build  
about 2-3 weeks old).

View raw message