-->
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.  [ 5 posts ] 
Author Message
 Post subject: Performance problem with cascade delete
PostPosted: Fri Jul 16, 2004 12:23 pm 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Hi everyone,

I've got an object A that has a set of object B that itself has a set of object C
Both sets have the option cascade="all-delete-orphan"

Each A can have up to 10000 object B in its set. And each B have 3 object C in its set.

So when deleting several A object, it's like deleting couple of 30000 linked objects.

Hibernate loads every C object and then fire a delete request for each of them. It takes a very long time and put a very high load on the DB.
If I trigger it on the DB itself it's done instantly (with the right casscade options)

I was thinking of using the batch-size option, but still it's not going to be as fast as the db.

Is there any other way to speed up this deletion process??

regards,
nodje


Last edited by nodje on Tue Jun 03, 2008 5:32 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 17, 2004 10:02 am 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
If you really need to delete thousands of objects, I think best way would be to simply use session.connection, and use a few jdbc statements on the returned jdbc connection...

There are some tips in the manual on deleting that might help however if you really need to do this in an OO way

http://www.hibernate.org/hib_docs/refer ... shotdelete


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 4:00 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Well this is a db cleanup operation that the user will launch once a year.
Even though, there'll be so much element that it will take ages. So I need to speed up the process anyway.

Using jdbc statement seems to be a very fair option, the only question is:
Will this keep my 2nd level cache (ehcache) synchromized or will I have to do it manually?

(I don't even know if it's possible to tell the cache some object disapeared from the db, I thing only emptying the cache via evict() is possible)

regards,
nodje


Last edited by nodje on Tue Jun 03, 2008 5:38 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 4:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You have to manually evict the cache.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 5:13 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Right, if I do evict them from the cache, the concerned objects won't be available if some process tries to load them.

But if I don't do that in an OO way, it's like an external process modifying the DB. And resynchronizing the cache might no be enough. HIbernate itself need to be resynchrinized. Some process might be using some of the object that are going to be deleted. In this case an instance of a deleted object might be left in memory.
Am I right here, or is the evict() method taking care of the in-memory object instances??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.