[CDBI] Do cascading deletes faster

Ask Bjørn Hansen ask at develooper.com
Sun Feb 5 03:11:51 GMT 2006


Two tables:  "servers" and "log_scores".  Sometimes there are tens of  
thousands of log_scores per server.  When I delete a server I'd like  
to make it go faster, so I naively added a before_delete trigger like

__PACKAGE__->add_trigger(before_delete =>
                          sub { NTPPool::Server::LogScore- 
 >delete_server($_[0])  }

(delete_server then does a simple $dbh->do to delete all the servers  
without loading them etc).

This would be okay for me because there isn't anything cascading from  
the LogScore class (and no triggers or some such).

It doesn't work though.  I didn't look closely, but it seems like  
Class::DBI still does the cascading deletes (or at least the select)  

I solved it by just adding { cascade => 'None' } to the has_many(),  
but it seems like it should have worked the other way.

The code is at

  - ask


More information about the ClassDBI mailing list