If you have referential integrity on your database it might slow things down a lot. Consider dropping the database and re-creating it, perhaps by executing an external script which could be easily changed. Perhaps you do not actually need Perl code to do this.