Re: [CDBI] Do cascading deletes faster

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

From: Matt S Trout
Subject: Re: [CDBI] Do cascading deletes faster
Date: 22:48 on 05 Feb 2006
On Sat, Feb 04, 2006 at 07:11:51PM -0800, Ask Bj=F8rn Hansen wrote:
> Hi,
>=20
> Two tables:  "servers" and "log_scores".  Sometimes there are tens of =20
> thousands of log_scores per server.  When I delete a server I'd like =20
> to make it go faster, so I naively added a before_delete trigger like
>=20
> __PACKAGE__->add_trigger(before_delete =3D>
>                          sub { NTPPool::Server::LogScore-=20
> >delete_server($_[0])  }
>                          );
>=20
> (delete_server then does a simple $dbh->do to delete all the servers =20
> without loading them etc).
>=20
> This would be okay for me because there isn't anything cascading from =20
> the LogScore class (and no triggers or some such).
>=20
> It doesn't work though.  I didn't look closely, but it seems like =20
> Class::DBI still does the cascading deletes (or at least the select) =20
> first.

That's because Class::DBI uses triggers to implement cascade delete, and
you're calling add_trigger after has_many. Try putting the add_trigger fi=
rst;
that way your trigger should be the first one to run.

--=20
     Matt S Trout       Offering custom development, consultancy and supp=
ort
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Con=
tact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more informat=
ion

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co=
.uk/ +

_______________________________________________
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