title: Optimize Delete
body: <p>I have a importer system which updates the column of already existing rows in a Table. Since UPDATE was taking time I changed it to DELETE and BULK INSERT.</p>
  
  <p>Here is my database setup snippet</p>
  
  <pre><code>Table: ParameterDefinition
  Columns: Id, Name, Other Cols
  
  Table: ParameterValue
  Columns: Id, CustId, ParameterDefId, Value
  </code></pre>
  
  <p>I get the values associated to ParamterDefinition.Name from my XML source, so to import I first delete all the existing ParamterValue with all the ParamterDefinition.Name passed in the XML and finally do bulk insert of all the values from XML. Here is my query</p>
  
  <pre><code>DELETE FROM ParameterValue WHERE CustId = ? AND ParameterDefId IN (?,?...?);
  </code></pre>
  
  <p>For 1000 Customers the above DELETE statement is called 1000 times which is very time consuming now, approximately 64 seconds. </p>
  
  <p>Is there any better way to handle DELETE of 1000 customers? </p>
  
  <p>Thanks,</p>
  
  <p>Sheeju</p>