[Dbix-class] Update first X rows

Yves Räber yraber at mailup.net
Thu Jul 16 14:16:12 GMT 2009


Thank you. 

Now it's very clear.

----- Original Message -----
From: "Peter Rabbitson" <rabbit+dbic at rabbit.us>
To: "DBIx::Class user and developer list" <dbix-class at lists.scsys.co.uk>
Sent: Thursday, July 16, 2009 3:31:23 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Re: [Dbix-class] Update first X rows

On Thu, Jul 16, 2009 at 01:53:39PM +0200, Yves Räber wrote:
> Thanks for your explanation. But things are still not clear for me.
> 
> If I create a resulset with a "rows" argument and then
> 
> 1/ Get all  the rows with a ->all method : It generate a "SELECT ... LIMIT rowcount" that's perfect
> 2/ Update the rows with a ->update( { whatever => 1 }) : It generates a "UPDATE ..." but ignores the limit
> 
> The slow and foolpoof method would be to update the rows one by one and stop after X elements, but it's not what it is doing. 
> 

Sigh. It really helps if you read what people point you to (I am referring
to the function I mentioned in previous mails). Once gain - the *default*
way to do $rs->update will _never_ add a limit to the query, as limit
is simply not portable (see SQL::Abstract::Limit). The "slow and foolproof
method" we use is to:

1) start a transaction
2) *SELECT* (not update) all rows that we would want to update
3) iterate over the result and update rows one by one
4) wrap up transaction

Guess which one of the points contains the actual limit, and read the
damned trace.

To summarize - everything works correctly, this is not a bug, it is just
inefficient. I already outlined what needs to be done to make it happen,
and it will happen when someone gets the time to do it.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



More information about the DBIx-Class mailing list