openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Slow performance with OpenJPA when selecting from a ManyToMany relation.
Date Thu, 12 Mar 2009 18:24:36 GMT
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 <marius.jones@broadpark.no> 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 <marius.jones@broadpark.no>
> > 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<Storagecategory> storageCategories;
> >>
> >>        public Wearhouse() {
> >>        }
> >>
> >>        public Wearhouse(String wearhouseName) {
> >>                this.wearhouseName = wearhouseName;
> >>                storageCategories = new ArrayList<Storagecategory>();
> >>        }
> >>
> >>        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>
> >> storageCategory){
> >>                this.storageCategories = storageCategory;
> >>        }
> >>
> >>        public List<Storagecategory> getStorageCategories(){
> >>                return storageCategories;
> >>        }
> >>
> >>        public void addStorageCategories(Storagecategory storagecategory)
> >> {
> >>                if(storageCategories == null)
> >>                        storageCategories = new
> >> ArrayList<Storagecategory>();
> >>                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<Wearhouse> 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<Wearhouse> getWearhouses() {
> >>                return wearhouses;
> >>        }
> >>
> >>        public void setWearhouses(List<Wearhouse> 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.
>
>

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