http://www.perlmonks.org?node_id=682708


in reply to DBI Question: bulk insertion with Unique-key constraint

IMO, the best way to avoid the problem is to not allow it to be a problem in the first place.

You can do this by generating two files, one where all of the rows are guaranteed to unique, and then everything else would be treated as an exception.

Your system will need to intelligently create your bulk insert files to provide the appropriate indices (if it's not able to do that inherently), and to detect for unique key collisions.

I wouldn't think that time would be any consideration for just 200k records.

For the exceptions file, you would then have your preprocessor generate the appropriate SQL script to facilitate the updates.


Your wish is my commandline.