openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <>
Subject Re: Multiple join fetches
Date Fri, 10 Apr 2009 01:20:21 GMT
On Tue, Apr 7, 2009 at 1:11 AM, Jay McHugh <> wrote:

> FetchPlan plan = em.getFetchPlan();
> plan.addField(GrandParent.class, "parents");
> plan.addField(Parent.class, "children");
> Query query = em.createQuery("select gp from GrandParent as gp");
I gave this a good testing and have some interesting (to me) results. My
real object model isn't quite like this, it's a little more complicated.
What I am doing is retrieving the root object, then traversing the hierarchy
and printing it out. If I use all LAZY annotations and no fetch plan (worse
case) it takes 3.2 seconds and runs 113 queries (which are interleaved with
my print statements). Adding the fetch plan as described above, it takes 1.8
seconds and runs 96 queries (which run before any print statements). Quite a
jump in speed but still a lot of queries. If I add the one join fetch to my
query it drops to 1.5 seconds and only 24 queries. Honestly I was expecting
it to generate one query and run very fast. Do these numbers make sense?

Daryl Stultz
6 Degrees Software and Consulting, Inc.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message