Re: Efficient way to delete lots of rows at a time?

2008-02-06 Thread Thomas Vandahl

brainville wrote:

What I have noticed, though, is that the doDelete method seems to be
performing a select, then executing a separate delete statement for each
returned row.  In one specific example, there are 12000 people that belong
to a category -- that's 12000 separate delete statements.  Is there a better
option than this? 


The library under the hood of Torque - Village - is responsible for this 
behaviour. There is BasePeer.deleteAll() to circumvent this limitation, 
clumsy as it may be. We promise improvement for version 4.0.


Bye, Thomas.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Efficient way to delete lots of rows at a time?

2008-02-05 Thread brainville

Hello,

I'm using Torque 3.3, and I have a situation where I'm trying to delete a
large number of rows from a mapping table at once.  In my case, I have a
Category table, a Person table, and a mapping table that lists which people
belong to which categories.  When a user deletes a category, I of course
first have to delete the records from the mapping table.  To do this, I am
doing the following:

public void deleteCategoryFromMap( String categoryId ) {
Criteria c = new Criteria();
c.add(CategoryMapPeer.FK_CATEGORY_ID, categoryId);
CategoryMapPeer.doDelete(c);
}

What I have noticed, though, is that the doDelete method seems to be
performing a select, then executing a separate delete statement for each
returned row.  In one specific example, there are 12000 people that belong
to a category -- that's 12000 separate delete statements.  Is there a better
option than this? 

CategoryMapPeer.executeStatement(delete from  + CategoryMapPeer.TABLE_NAME
+  where  + CategoryMapPeer.FK_CATEGORY_ID +  = ' + categoryId + ');

Thanks..

Ben Rainville
-- 
View this message in context: 
http://www.nabble.com/Efficient-way-to-delete-lots-of-rows-at-a-time--tp15299799p15299799.html
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]