SQL Performance - Better to Insert and Raise Exception or Check exists?
问题 I'm considering an optimisation in a particularly heavy part of my code. It's task is to insert statistical data into a table. This data is being hit a fair amount by other programs. Otherwise I would consider using SQL Bulk inserts etc. So my question is... Is it ok to try and insert some data knowing that it might (not too often) throw a SqlException for a duplicate row? Is the performance hit of an exception worse than checking each row prior to insertion? 回答1: First, my advice is to err