while (things_to_process) { $schema->txn_do(sub { # insert your 1000 rows here }); }