Just a short tip:
The REPLACE function from MYSQL. It checks if the row is existing, and doing an INSERT (if not), or an UPDATE (if it is). However if you do not want the UPDATE feature, it does not help you.
Re: How to count rows using DBI & mysql - Performance results
Replies are listed 'Best First'.