in reply to Optimizing mysql and inserts

First you need to identify the bottleneck(s). Comment all the lines with $dbh and see if it speeds up or not.

Also, truncate entry; will be faster than delete from entry;