SQL SERVER – Delete All Waiting Workflows in MSCRM to Speed Up Microsoft Dynamics

SQL
No Comments

Last week, during performance tuning consultancy, I faced a very interesting situation when customer’s Microsoft Dynamics CRM was extremely slow. After quickly researched we found that they have a very high number of Mass Waiting Task Workflows in the system. They honestly did not care about those anymore as they were stuck there waiting for over a year and have no meaning at this point of time.

SQL SERVER - Delete All Waiting Workflows in MSCRM to Speed Up Microsoft Dynamics msdynamics

Due to the high number of waiting workflows, data their insert, update and delete in their CRM system was getting extremely slow. After quickly researching online we figured out a way to delete all the waiting task workflow from MSCRM database. Please note that this is not official advice from Microsoft or even not something I they support. This is absolutely from what I have seen in the real world and how I fixed them.

I strongly recommend that you take a full database backup of your MSCRM system before you do following task. However, once deleted all the waiting workflows from MSCRM, the queries which were taking over 10 minutes, started to take less than 10 seconds.

Here is the script which you should run against your MSCRM database.

DELETE FROM workflowwaitsubscriptionbase
WHERE asyncoperationid in
(SELECT asyncoperationid
FROM asyncoperationbase
WHERE StateCode = 1)
GO
DELETE FROM workflowlogbase
WHERE asyncoperationid in
(SELECT asyncoperationid
FROM asyncoperationbase
WHERE StateCode = 1)
GO
DELETE FROM asyncoperationbase
WHERE StateCode = 1
GO

Reference: Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Database Disaster Recovery Process
Next Post
SQL SERVER – Find Week of the Year Using DatePart Function

Related Posts

Leave a Reply

Menu