working but sending mulitple requests per second on server and also skipping some condition compering my $query = $dbh->prepare("SELECT plates FROM pintable WHERE status =?"); $query->execute('OK'); while( my $row = $query->fetchrow_arrayref() ) { my $plates = $row->[0]; while ($STPU eq 'good') { # update DB with some data } $dbh->commit; } works great and not causing problems to server, but the problem it runs single task per running my $query = $dbh->prepare("SELECT plates FROM pintable WHERE status =?"); $query->execute('OK'); my $row = $query->fetchrow_arrayref(); my $plates = $row->[0]; if ($STPU eq 'good') { # update DB with some data } $dbh->commit;