With CRM 4.0 it was often the case that the Asynchronous processing service would start lagging due to the rapid growth of the AsyncOperationBase table in SQL getting to millions of records in just a few months. This was often happening because of the amount of workflows triggered in the system. For example, if you create a workflow that triggers every time an activity is updated, you might end up flooding the database with system job records very quickly.
Fortunately, in CRM 2011 there is a simple one-click solution that helps maintain the size of the AsyncOperationBasae table. If you open your workflow definition and go to the Administration tab, you will find the “Workflow Job Retention” option. If you click on the checkbox, it means that every time this workflow job is executed AND if it succeeds, the system job will be deleted. Selecting that option is perfect for processes that you don’t need to audit and you just need the logic to execute. However, if you need to keep a history of which workflows have executed on which records you should not select this option to delete the workflow job on completion (note that this option is disabled by default).
The same option is now available for asynchronous plugin steps as well:
This allows you to pick and choose which workflows and plugins are worth storing as system jobs every time they execute and which ones you want to delete upon completion to save space!
However, in order for the async auto-delete feature to take effect, you must first make sure that the “auto-delete” feature is enabled for the organization. There is a master switch that must be turned on:
select BitColumn from OrganizationProperties where ColumnName = 'AsyncRemoveCompletedJobs'
Note that you can have a different value in that setting for each organization. In CRM Online, this value is always 1 (enabled) for all organizations.
You will also notice there is an 'AsyncRemoveCompletedWorkflows' setting in OrganizationProperties. This setting has been deprecated in CRM 2011 so you can safely ignore it, since it has been replaced by the AsyncAutoDelete attribute in the workflow definition (Workflow Job Retention option).