-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Full table access - performance issue
PostPosted: Sun Feb 13, 2005 10:24 am 
Beginner
Beginner

Joined: Tue Jan 04, 2005 5:39 am
Posts: 37
Hibernate version: 2.1.8

Hi everybody! Here is the problem:

I have 5 tables and 5 classes: X, Y, I, G.
They are mapped with "one-to-many" as following:

X --one-to-many--> Y

I --one-to-many--> Y

I --one-to-many--> G

As you can see, there are 2 classes which are pointing to class Y.
In my program, i am loading class Y.
Loading of this class, should cause classes X and I to be loaded.

Now suppose that there is no data in table I, and the field in Y that points on I contains null. In that case there won't be any functional impact, because hibernate will generate OUTER-JOINS.

Those outer-joins will include joins:
1. from Y to X
2. from Y to I
3. from I to G

The problem is: because there is no data in table I, join #2 will retrieve no data, and join #3 will perform FULL TABLE SCAN.

My question is:
How to pervent this from happening?
Why does hibernate generate joins #2 and #3 despite there is null value in the relevant field in class Y?

Thanks a lot!
Michael.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 6:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Because when Hibernate does the query, there is no way to know that this field is null.
You should ask your DBA why your DB do a full scan in this case.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: take your hand and count
PostPosted: Mon Feb 14, 2005 7:00 am 
Newbie

Joined: Tue Aug 24, 2004 5:36 pm
Posts: 16
when using my hand and make a mapping to X Y I G, I could find only 4 classes and 4 tables. Thus I guess the full scan comes from the hidden table join.

Seriously, I suggest you configure hibernate to print out the generated queries and post them here.

Another guess is that table I is not really empty.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.