Skip to main content
Nintex Community Menu Bar

How to quickly check the health of your Nintex Workflow SQL Indexes

  • December 6, 2014
  • 1 reply
  • 94 views
  • Translate

Forum|alt.badge.img+10

Products: Nintex Workflow 2013, Nintex Workflow 2010

 

We often encounter a situation where the performance of a SharePoint farms workflow infrastructure could be drastically improved if fragmentation on Nintex Workflow databases were minimal. This script will provide a way to review the fragmentation of all table indexes inside of the Nintex Workflow ConfigurationStandalone Content database.

 

Run the below (attached as well as a *.txt file for your convenience) PowerShell script (PowerShell ISE works well) from a SharePoint Server:

 

 

PowerShell Script
  1. Add-PSSnapin Microsoft.SharePoint.PowerShell
  2.  
  3. [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
  4. [void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow")
  5. [void][System.Reflection.Assembly]::LoadWithPartialName("Nintex.Workflow.Administration")
  6.  
  7. $cmd = New-Object -TypeName System.Data.SqlClient.SqlCommand
  8.  
  9. $cmd.CommandType = [System.Data.CommandType]::Text
  10.  
  11. $cmd.CommandText = "SELECT OBJECT_NAME(i.object_id) AS TableName ,i.name AS TableIndexName ,phystat.avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') phystat inner JOIN sys.indexes i ON i.object_id = phystat.object_id AND i.index_id = phystat.index_id WHERE phystat.avg_fragmentation_in_percent > 10"
  12.  
  13.  
  14. $reader = [Nintex.Workflow.Administration.ConfigurationDatabase]::GetConfigurationDatabase().ExecuteReader($cmd)
  15.  
  16. $indexes = @()
  17.  
  18. while($reader.Read())
  19. {
  20.     $row = New-Object System.Object
  21.  
  22.     $row | Add-Member -MemberType NoteProperty -Name "TableName" -Value $reader["TableName"]
  23.     $row | Add-Member -MemberType NoteProperty -Name "TableIndexName" -Value $reader["TableIndexName"]
  24.     $row | Add-Member -MemberType NoteProperty -Name "avg_fragmentation_in_percent" -Value $reader["avg_fragmentation_in_percent"]
  25.  
  26.  
  27. $indexes += $row
  28. }
  29.  
  30. $indexes
 

 

To use the script do the following:

  • Ensure you are running the PowerShell console as a SharePoint Administrative account.
Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img+1

My script fails on the line that uses:

[Nintex.Workflow.Administration.ConfigurationDatabase]

Please advise.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings