[CDBI] Do cascading deletes faster

[prev] [thread] [next] [Date index for 2006/02/05]

From: =?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?=
Subject: [CDBI] Do cascading deletes faster
Date: 03:11 on 05 Feb 2006
Hi,

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)  
first.

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
	https://svn.develooper.com/projects/ntppool/trunk/lib/NTPPool/Server.pm
	https://svn.develooper.com/projects/ntppool/trunk/lib/NTPPool/Server/ 
LogScore.pm


  - ask

        -- 
        http://www.askbjoernhansen.com/



_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] Do cascading deletes faster
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 03:11 on 05 Feb 2006

Re: [CDBI] Do cascading deletes faster
Matt S Trout 22:48 on 05 Feb 2006

Generated at 20:45 on 01 Mar 2006 by mariachi v0.52