in reply to DBI vs Bulk Loading

the best way insert, speed wise, is to write the digested data to a CSV and bulk load it. What I need help with is how to duplicate my PK violation logic with this method.

Er, um, the bulk loading method is for, well, bulk loading. This usually means loading a dumpfile from somewhere else (be it a backup of the database, or a big chunk from somewhere else, etc). The bulk loading facilities are fast because they avoid a lot of the work a normal insert does.

But most of the time, you want that work to be done. You want to let the database do this for you, so you don't have to. Having to do all the stuff you're skipping might end up costing as much as you're saving with the bulk loading, and it creates a lot of work, more potential bugs, and all manner of headaches. In short, only use bulk loading facilities when you're actually bulk loading.