Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 55906 invoked from network); 12 Mar 2009 18:25:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2009 18:25:08 -0000 Received: (qmail 88403 invoked by uid 500); 12 Mar 2009 18:25:07 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 88381 invoked by uid 500); 12 Mar 2009 18:25:07 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 88370 invoked by uid 99); 12 Mar 2009 18:25:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Mar 2009 11:25:07 -0700 X-ASF-Spam-Status: No, hits=2.4 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kwsutter@gmail.com designates 209.85.217.174 as permitted sender) Received: from [209.85.217.174] (HELO mail-gx0-f174.google.com) (209.85.217.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Mar 2009 18:24:57 +0000 Received: by gxk22 with SMTP id 22so3179617gxk.9 for ; Thu, 12 Mar 2009 11:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=qRRolrjorFSF26YXS6BgzVEZTFiRSqKKteaawf/cf+o=; b=i8Zv+FJbXtbu7ld+gMcFil6Fkm5dVwSZfv9fspfVpLDNgxzjjLZ6Z4FJsw+BOTbIt/ lCychhBguwgThFMGhf5IA+Tvz/dtbr8BLtbW0jC6prhT15bFZ8SbU9VUXnHpJoK0n9L4 Ahm1im8UaQ6gV6M7P9EUNaGfAqUV0Iu152m/Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=xGPf1+fEqGpnJ01031/X6WSuSaQVFb988Z+3+xLrt6HGFictfwAijE8nawqsR4343S Mhe5N7UesoucOJrH8kn3+iI3f3L7pDSk9zNvHWtEsq7XGyAVHq8RA/RHGffIfgYu0ngD mmpAhzNPQrZ/p2snEuC8N6r/8PKSeaVVqjY98= MIME-Version: 1.0 Received: by 10.151.98.11 with SMTP id a11mr549155ybm.146.1236882276235; Thu, 12 Mar 2009 11:24:36 -0700 (PDT) In-Reply-To: <1236865724731-2467417.post@n2.nabble.com> References: <1236860524615-2466994.post@n2.nabble.com> <89c0c52c0903120638x4692516dg9741585505a5b361@mail.gmail.com> <1236865724731-2467417.post@n2.nabble.com> Date: Thu, 12 Mar 2009 13:24:36 -0500 Message-ID: <89c0c52c0903121124r1f4592ccy58592b2197c928f9@mail.gmail.com> Subject: Re: Slow performance with OpenJPA when selecting from a ManyToMany relation. From: Kevin Sutter To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0015174c1996b44f2c0464f0182f X-Virus-Checked: Checked by ClamAV on apache.org --0015174c1996b44f2c0464f0182f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Shubbis, Darn, I thought it was going to be an easy "lack of enhancement" question... Your results don't seem to mesh what we have been experiencing, but let me try to mimic your exact setup and see what I come up with. I do see that you are using Eager FetchType. Is your database fully populated? That is, what number of Wearhouse and StorageContainers are you running with? And, have you verified that the FetchType of Eager is working for all implementations? And, what version of OpenJPA are you running with? 1.0.x, 1.2.x, 1.3.x, or trunk (2.0.x)? And, any caching parameters at all? Or, just plain vanilla out-of-the-box configuration? Thanks, Kevin On Thu, Mar 12, 2009 at 8:48 AM, Shubbis wrote: > > Hi Kevin, > > Thanks for the reply! > > We are enhancing the files. I have an Ant script enhancing the files before > every run of OpenJPA, so that is not the problem. > Although it did give me strange results the first time I tried openjpa and > did not enhance ;) > > -Shubbis > > > Kevin Sutter wrote: > > > > Hi Shubbis, > > Thanks for asking before posting any results... :-) Much appreciated. > > > > The first thing that comes to mind is whether you are "enhancing" your > > Entities that are used with OpenJPA. For optimal performance, OpenJPA > > uses > > a byte-code weaving technique to enhance the Entity objects. This > > enhancement allows for more efficient interaction between the Entity > > objects > > and the OpenJPA runtime. > > > > This blog entry explains the various enhancement mechanisms available for > > an > > OpenJPA environment (build vs runtime): > > > http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html > > > > FYI, if you do not perform the byte-code enhancement either statically at > > build time or dynamically at runtime, then OpenJPA falls back to a > simpler > > subclassing approach. This subclassing approach is meant for simple > > out-of-the-box examples, and not for production or performance > > comparisons. > > This performance concern becomes especially noticeable with Eager type > > relationship fetching like it looks your example is doing. > > > > Let's start with this enhancement processing. If you are doing > > enhancement > > and you are still hitting this performance concern, then we need to dig > > further because we definitely do not see this type of performance concern > > when we do our comparisons... :-) > > > > Thanks, > > Kevin > > > > On Thu, Mar 12, 2009 at 7:22 AM, Shubbis > > wrote: > > > >> > >> First post so bare with me, and I've search for quite a while and not > >> found > >> any answers. > >> > >> I'm working on a school project where we are testing performance with > >> different ORM's compared to JDBC and I'm having a big issue with OpenJPA > >> when using a ManyToMany relation. > >> > >> We're trying to do a simple select case where we run a for loop with 500 > >> iterations while calling a findById method that returns the instance. > >> > >> Wearhouse instance = getOJPAEntityManager().find(Wearhouse.class, id); > >> > >> This takes roughly 1~ sec on JDBC and 1.2~ EclipseLink while it takes > 10+ > >> sec on OpenJPA. > >> This only happens with ManyToMany! We have plenty of insert tests, > select > >> tests etc and all of them are much more similar, with openjpa winning > and > >> losing a few. > >> > >> Now, I'll gladly admit we dont have to much experience with this, but > >> this > >> strikes me as very odd. So, if anyone has any tips, comments or info > I'll > >> be > >> glad to try it out. > >> > >> Thanks in advance! > >> > >> Marius > >> > >> Here are the two entities in question: > >> > >> package project.common.model; > >> > >> import java.util.*; > >> > >> import javax.persistence.*; > >> > >> @Entity > >> public class Wearhouse { > >> > >> @Id > >> @GeneratedValue(strategy = GenerationType.IDENTITY) > >> private Integer wearhouseNr; > >> private String wearhouseName; > >> > >> @ManyToMany(cascade={CascadeType.PERSIST}, fetch = > >> FetchType.EAGER) > >> @JoinTable( > >> name="wearhouse_storagecategory", > >> joinColumns=@JoinColumn(name="wearhouseNr"), > >> > >> inverseJoinColumns=@JoinColumn(name="storagecategoryNr") > >> ) > >> private List storageCategories; > >> > >> public Wearhouse() { > >> } > >> > >> public Wearhouse(String wearhouseName) { > >> this.wearhouseName = wearhouseName; > >> storageCategories = new ArrayList(); > >> } > >> > >> public Integer getWearhouseNr() { > >> return this.wearhouseNr; > >> } > >> > >> public void setWearhouseNr(Integer wearhouseNr) { > >> this.wearhouseNr = wearhouseNr; > >> } > >> > >> public String getWearhouseName() { > >> return this.wearhouseName; > >> } > >> > >> public void setWearhouseName(String wearhouseName) { > >> this.wearhouseName = wearhouseName; > >> } > >> > >> public void setStorageCategories(List > >> storageCategory){ > >> this.storageCategories = storageCategory; > >> } > >> > >> public List getStorageCategories(){ > >> return storageCategories; > >> } > >> > >> public void addStorageCategories(Storagecategory storagecategory) > >> { > >> if(storageCategories == null) > >> storageCategories = new > >> ArrayList(); > >> storageCategories.add(storagecategory); > >> > >> } > >> > >> } > >> > >> > >> > >> package project.common.model; > >> > >> import java.util.*; > >> > >> import javax.persistence.*; > >> > >> @Entity > >> public class Storagecategory { > >> > >> @Id > >> @GeneratedValue(strategy = GenerationType.IDENTITY) > >> private Integer storagecategoryNr; > >> private String storageCategoryName; > >> > >> @ManyToMany(mappedBy="storageCategories", > >> cascade={CascadeType.PERSIST}) > >> private List wearhouses; > >> > >> public Storagecategory() { > >> } > >> > >> public Storagecategory(String storageCategoryName) { > >> this.storageCategoryName = storageCategoryName; > >> } > >> > >> public Integer getStoragecategoryNr() { > >> return this.storagecategoryNr; > >> } > >> > >> public void setStoragecategoryNr(Integer storagecategoryNr) { > >> this.storagecategoryNr = storagecategoryNr; > >> } > >> > >> public String getStorageCategoryName() { > >> return this.storageCategoryName; > >> } > >> > >> public void setStorageCategoryName(String storageCategoryName) { > >> this.storageCategoryName = storageCategoryName; > >> } > >> > >> public List getWearhouses() { > >> return wearhouses; > >> } > >> > >> public void setWearhouses(List wearhouses) { > >> this.wearhouses = wearhouses; > >> > >> //Wearhouse owns the relation, therefor we have to tell > >> these > >> //wearhouses this storargecategories is on of the > >> wearhouse's > >> storagecategories. > >> for (Wearhouse wearhouse : wearhouses) > >> wearhouse.addStorageCategories(this); > >> } > >> } > >> -- > >> View this message in context: > >> > http://n2.nabble.com/Slow-performance-with-OpenJPA-when-selecting-from-a-ManyToMany-relation.-tp2466994p2466994.html > >> Sent from the OpenJPA Users mailing list archive at Nabble.com. > >> > >> > > > > > > -- > View this message in context: > http://n2.nabble.com/Slow-performance-with-OpenJPA-when-selecting-from-a-ManyToMany-relation.-tp2466994p2467417.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > > --0015174c1996b44f2c0464f0182f--