How to purge large Nintex Workflow History list and dbo WorkflowProgress table

Not applicable
24 8 48.8K

Applies to the following products: Nintex Workflow 2010, Nintex Workflow 2013


How to purge items in a large Nintex Workflow History list.

If you have more than 5,000+ records in your Nintex workflow history list, you may need to review other options to purge these items as the GUI may fail its purge operation.


History List Purge Method 1


Using NWAdmin.exe -o PurgeHistoryListData

NWAdmin.exe is included as a part of your Nintex install. Here is an example using the PurgeHistoryListData:

SharePoint 2013 Management Shell:

NWAdmin.exe –o PurgeHistoryListData -siteUrl -lastActivityBefore 2014-07-01 00:00 -state SELECT STATE‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Specify to remove history list items for workflows that have a state of Running, Completed, Cancelled, Error or All state. The default is Completed if -State is left off.

Don't use "-state All" in production. Only purge completed workflows that you don't need to review the history of. If you purge running instance data, it will not be able to continue.


To get the correct format for the -lastActivityBefore and -lastActivityBeforeUTC switches use this command in Power-Shell:

SharePoint 2013 Management Shell:

Get-Date -Format -s‍‍‍


Please note: PurgeHistoryListData needs to be run for each Site in your Site Collection that uses Nintex Workflow. You can identify sites that have large history lists in your SharePoint farm by using the following script: How to quickly identify large lists in SharePoint


More information on NWAdmin.exe commands and switches can be found here:


If the NWAdmin.exe PurgeHistoryListData approach fails to clear out items you can then try the PowerShell script bellow.


History List Purge Method 2


Using PowerShell to purge items

You can find the script here: How to purge items from a large history list safely via PowerShell

This script utilizes paging and indexing to specifically target each item and delete it. Paging helps throttle the traffic to your SQL server down by only deleting x number of items at a time before it rests and starts again. Indexing enables the targeting of items without the performance overhead of enumerating and/or querying a large collection of items.


How to purge large dbo.WorkflowProgress table data.

If you find you have 5,000,000 or more rows in your Nintex dbo.WorkflowProgress table then you will need to consider trimming some records. You can do this using the below options.




Only perform a dbo.WorkflowProgress clean up AFTER you have purged data from your Nintex workflow history lists. Not doing so will prevent you from purging items from the history list using the "PurgeHistoryListData" command unless the "-clearall" switch is used.



dbo.WorkflowProgress table purge Method 1


Using NWAdmin.exe -o PurgeWorkflowData

The first step we recommend is using our NWAdmin.exe command. Here is an example using the PurgeWorkflowData operation:

SharePoint 2013 Management Shell:

NWAdmin.exe -o PurgeWorkflowData -state SELECT STATE‍‍‍ -url -lastActivityBeforeLocal 2014-07-01T00:00:00‍


Specify to remove history list items for workflows that have a state of Running, Completed, Cancelled, Error or All state. The default is Completed if -State is left off.

Don't use "-state All" in production. Only purge completed workflows that you don't need to review the history of. If you purge running instance data, it will not be able to continue.

Again, you can find more information on the NWAdmin.exe command here:


dbo.WorkflowProgress table purge Method 2


Using a SQL Script to purge records

If NWAdmin.exe -o PurgeWorkflowData fails to purge the records out of your dbo.WorkflowProgress table, our next recommendation is to use the following SQL script:


First you will need to gather the SiteID's for the site collection's you would like to purge data from. To do this run the following power-shell command:

SharePoint 2013 Management Shell:

Get-SPSite -limit all | SELECT URL, ID, RootWeb‍‍‍‍‍‍‍


Afterword run the following query to retrieve the number of remaining records per site collection:


SELECT COUNT (*)as RecordsPerSiteCollection,I.SiteID
FROM WorkflowInstance I 
inner join WorkflowProgress P
ON I.InstanceID = P.InstanceID 
--WHERE siteid = 'YOUR SITE COLLECTION GUID' --Update to your Site Collection ID


Here is an example of the output of this script:



To clear records for a specific site collection with a last activity date less than 2014-07-01 (See additional filters at the bottom including doing purge per site😞


DECLARE @return_value int
EXEC @return_value = [dbo].[PurgeWorkflowData]
@SiteID='YOUR SITE COLLECTION GUID', --Update to your Site Collection ID
@LastActivityDate = '2014-07-01' --Setting lastworkflowactivity time, this is actions executed older than the date specified
SELECT 'Return Value' = @return_value


You can also use one or more of the following parameters to fine-tune the query to limit the information that is removed:


@workflowname <Exact Name of workflow>
@listid <GUID>
@state <##>--Running = 2, Completed = 4, Cancelled = 8, Error = 64
@instanceid <GUID>
@webid <GUID> --Site/Sub Site
@siteid <GUID> --Site Collection
@itemid <GUID>
@lastActivityDate <Date of last activity execution>
@initiator <UserName>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Not applicable

Done, thank you.

Nintex Newbie

Hi Pavel,

We are running Nintex Workflow for SharePoint 2010 on SharePoint 2010 Enterprise 14.0.7155.5000.

The other day i reduced our Nintex Workflow by dividing the data over several database.

Before i did this i was trying to reduce the massive size of 245Gb with regular purging but this would time out.

I ran into your blog and used the SQL command to clear the log. Somehow i missed the "state" parameter and deleted everything from certain workflows. Everything seemed fine though. Now it turns out some workflows are running twice. what can i do?

Kindest regards

Marc Plet


Nintex Newbie

Hi , 

when the list item status got completed, that item disappears from the list,

when i check purge data, i can see the item there,

But my client don't need that option, is there any option to bring it back to list.

Nintex Newbie

Any advice on doing this for Office 365?

Canvas Initiate

The command for getting the date in string format is actually: get-date -format s  

Design Dabbler

hello i am getting below error when i try to purge dbo.workflowprogress table using sharepoint management shell.

I did this process earlier but without any error, but now i am being thrown this error even though i try all the date formats.


ERROR: "Command line error: String was not recognized as a valid DateTime."


NWAdmin.exe -o PurgeWorkflowData -state Completed -siteCollectionUrl -lastActivityBeforeLocal 09/31/2020 -timeout 600

Community Manager Community Manager
Community Manager

@AshMa it looks like you need to put the datatime into the following format: 


I believe that the / character in your command is what is causing you that issue. 

Nintex Newbie


I actually got confused now. I deleted the record for particular item from nintex workflowinstance view using SQL stored procedure. However, I delete only single records, my wf progress table reduces the count by many numbers. may I know the reason for this.