in reply to Deleting Multiple MySQL Rows With DBI
If @MESSAGE_IDS is really large, consider breaking it up into smaller arrays when doing the above on each slice. Something like:my $sth=$dbh->prepare("DELETE FROM table WHERE ". join(" or ",map { "message_id = $_" } @MESSAGE_IDS));
Update: Or listen to lhoward :) He's got the best answer, I think. I also didn't realize you could do what beatnik suggested. I guess my SQL is off.while (@MESSAGE_IDS) { my @todel=splice @MESSAGE_IDS,0,10; my $sth=$dbh->prepare("DELETE FROM table WHERE ". join(" or ",map { "message_id = $_" } @todel)); $sth->execute; }
|
|---|