locked
Deleting records via CRM web service RRS feed

  • Question

  • Hi, I have a list of about 40 000 records to delete from CRM. I extracted ids with sql query, it is not possible to create such a query in advanced find. Hence, I don't use bulk delete job. Deleting via web service (IOrganizationService.Delete) goes very slow (I am not sure why, maybe because of related records, there is no registered plugin which triggers). Does anybody know of any more efficient way to do this or why is web service call so slow?

    Thanks in advance


    Zarko

    Monday, October 28, 2013 11:45 AM

All replies

  • Hi, web service delete one by one all 40000 records.

    It's slow

    if you don't have any plugins or workflow for delete your entity. You can delete records from SQL.

    It's not support but it's fast.

    Or you can use ExecuteMultipleRequest.

    but ExecuteMultipleRequest can process only 1000 requests

    • Edited by g.Naukovych Monday, October 28, 2013 12:54 PM
    Monday, October 28, 2013 12:20 PM
  • No, I haven't. As I said, I can't define a query expression for the data I need. But if I have the ids of entities, is it a problem to set expression with In operator and couple of thousend ids in a collection?

    Zarko

    Tuesday, October 29, 2013 7:17 AM
  • The executemultiple actually does process more than 1000 records, it just does so in batches of 1,000 so it can still be used. I used a WPF app to use the executemultiple on the backend to delete some legacy entities post-upgrade recently, and it will work with and entity that supports a deleterequest.

    As far as the query expression reading all those id's, I don't see a reason why it wouldn't, it may not optimally perform, but it sounds like this is a one time event, so you could do that.


    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful. Michael Mayo

    Friday, November 1, 2013 9:27 PM
  • Thank you for suggestion, I am using a bulk delete job, created programatically. It does not solve my problem unfortunately, deleting goes very slow, I am considering putting a new index on these 2 tables of custom entities.
    Monday, November 4, 2013 1:35 PM
    • The main performance benefit of ExecuteMultiple is when you have low latency network connections to the CRM Server; if you're running OnPremise, with code running on the server, it won't help that much
    • Adding indexes would only make this slower. The delete operation will always find the record via the primary key, whcih will already be indexed on the base and extensionbase tables. Adding further indexes just means more indexes for SQL to update, which will take longer. The only excpetion to this is you have cascading delete rules to child entities. If so, ensure you have an index on the foreign key in those entities
    • Using In with up to 2000 ids in a collection is a reasonable approach. You can't go much above 2000 ids, as you hit the limit of SQL parameters in one request

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Tuesday, November 5, 2013 9:41 AM
    Moderator
  • Thank you for this useful information, but I still don't get why is the deletion job so slow. It took 5 hours for 2000 ids.
    Tuesday, November 5, 2013 2:59 PM