localObject vs prefetches: would there be a benefit ?

From: Marcin Skladaniec (marci..sh.com.au)
Date: Thu Nov 01 2007 - 20:50:40 EDT

  • Next message: Mike Kienenberger: "Re: localObject vs prefetches: would there be a benefit ?"

    Hi

    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);
    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
    p2.getGallery().getCity();
    //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
    records.

    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).

    Marcin




    This archive was generated by hypermail 2.0.0 : Thu Nov 01 2007 - 20:51:15 EDT