Quickly Reindex WSUS Database using T-SQL Script

In this article, I will show you how to reindex WSUS database using T-SQL Script. Re-indexing the WSUS database improves the performance of WSUS and WSUS deployments.

When you have a stand-alone WSUS server that is used for deploying the updates, over the time the performance of database degrades. This is a known issue for WSUS administrators.

To improve the performance of WSUS database, you can run a simple T-SQL script which is a WSUSDBMaintenance script to reindex and de-fragment WSUS databases.

The performance of large WSUS deployments will degrade over time if the WSUS database isn’t maintained properly. Hence, you have to put extra efforts to maintain and rebuild the WSUS database.

There are two ways to reindex WSUS database depending on how it’s installed.

  • If you are using Windows Internal Database, you will need to use the sqlcmd utility, which can be downloaded from docs.microsoft.com SQLCMD page.
  • If the WSUS DB is located on SQL Server, you can run the WSUSDBMaintenance script (T-SQL script) against the database using SQL Server Management Studio.

Note: You should not use WSUSDBMaintenance script on WSUS 2.0 databases as it is not supported.

What does the WSUSDBMaintenance script do?

This WSUSDBMaintenance script does basic maintenance tasks on SUSDB:

  • Identify indexes that are fragmented, and defragments them.
  • For certain tables, a fill factor is set to improve insert performance.
  • Updates potentially out-of-date table statistics.
  • Improves the performance of WSUS database.

Download the WSUSDBMaintenance T-SQL Script

You can download the WSUSDBMaintenance T-SQL Script from Microsoft documentation. You can either copy the script and run it against the SUSDB or save the script to a file and run it in SSMS.

Steps to Reindex WSUS Database

To Reindex WSUS Database using T-SQL Script:

  • Launch the SQL Server Management Studio.
  • Connect to Database engine with your credentials.
  • Expand Databases, right-click SUSDB and select New Query.
Reindex WSUS Database using T-SQL Script
Reindex WSUS Database using T-SQL Script

In the query window, paste the WSUSDBMaintenance script (T-SQL script) and click Execute.

Reindex WSUS Database using T-SQL Script
Reindex WSUS Database using T-SQL Script

Wait for the T-SQL Script to run. The script reindexes and defragments the WSUS database. The following lines in the query output confirm that reindex WSUS database operation has been completed successfully.

Statistics for all tables have been updated.
Done updating statistics.2022-04-13 15:00:23.490
Completion time: 2022-04-13T15:00:23.5018971+05:30
Reindex WSUS Database using T-SQL Script
Reindex WSUS Database using T-SQL Script

The below output is of the WSUS Database maintenance script. I have added this for my reference.

Estimating fragmentation: Begin. 2022-04-13 14:59:54.203
Number of indexes to rebuild: 53
Estimating fragmentation: End. 2022-04-13 14:59:56.287
2022-04-13 14:59:56.290 Executing: ALTER INDEX [nc1KBArticleForRevision] ON [dbo].[tbKBArticleForRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:56.303 Done.
2022-04-13 14:59:56.303 Executing: ALTER INDEX [PK__tbMoreIn__DF49EF3C638F0653] ON [dbo].[tbMoreInfoURLForRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:56.430 Done.
2022-04-13 14:59:56.430 Executing: ALTER INDEX [nc_RevisionID_ShortLanguage] ON [dbo].[tbMoreInfoURLForRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:56.520 Done.
2022-04-13 14:59:56.520 Executing: ALTER INDEX [nc1SecurityBulletinForRevision] ON [dbo].[tbSecurityBulletinForRevision] REBUILD
2022-04-13 14:59:56.523 Done.
2022-04-13 14:59:56.523 Executing: ALTER INDEX [PK__tbLocali__D4CFF3987CA3BCDC] ON [dbo].[tbLocalizedPropertyForRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:56.693 Done.
2022-04-13 14:59:56.693 Executing: ALTER INDEX [nc1LocalizedPropertyID] ON [dbo].[tbLocalizedPropertyForRevision] REORGANIZE
2022-04-13 14:59:57.020 Done.
2022-04-13 14:59:57.020 Executing: ALTER INDEX [PK__tbFileFo__42CF22AD880D1325] ON [dbo].[tbFileForRevision] REORGANIZE
2022-04-13 14:59:57.080 Done.
2022-04-13 14:59:57.080 Executing: ALTER INDEX [nc1FileForRevision] ON [dbo].[tbFileForRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.123 Done.
2022-04-13 14:59:57.123 Executing: ALTER INDEX [PK__tbFileHa__67EC15CE6D7F5C88] ON [dbo].[tbFileHash] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.147 Done.
2022-04-13 14:59:57.147 Executing: ALTER INDEX [PK__tbRevisi__43332583DDF5C093] ON [dbo].[tbRevisionSupersedesUpdate] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.193 Done.
2022-04-13 14:59:57.193 Executing: ALTER INDEX [nc1SupercededUpdateID] ON [dbo].[tbRevisionSupersedesUpdate] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.237 Done.
2022-04-13 14:59:57.237 Executing: ALTER INDEX [PK__tbInstal__C3A16224D78C8EC9] ON [dbo].[tbInstalledUpdateSufficientForPrerequisite] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.310 Done.
2022-04-13 14:59:57.313 Executing: ALTER INDEX [nc1InstalledUpdateSufficientForPrerequisite] ON [dbo].[tbInstalledUpdateSufficientForPrerequisite] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.383 Done.
2022-04-13 14:59:57.383 Executing: ALTER INDEX [tbBundleAtLeastOne_PK] ON [dbo].[tbBundleAtLeastOne] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.393 Done.
2022-04-13 14:59:57.393 Executing: ALTER INDEX [PK__tbPrereq__4E62540B6C754374] ON [dbo].[tbPrerequisiteDependency] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.483 Done.
2022-04-13 14:59:57.483 Executing: ALTER INDEX [nc1PrerequisiteDependency] ON [dbo].[tbPrerequisiteDependency] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.560 Done.
2022-04-13 14:59:57.560 Executing: ALTER INDEX [nc2PrerequisiteDependency] ON [dbo].[tbPrerequisiteDependency] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.670 Done.
2022-04-13 14:59:57.670 Executing: ALTER INDEX [nc1BundleDependency] ON [dbo].[tbBundleDependency] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.680 Done.
2022-04-13 14:59:57.680 Executing: ALTER INDEX [nc_LocalUpdateID] ON [dbo].[ivwApiUpdateRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.693 Done.
2022-04-13 14:59:57.693 Executing: ALTER INDEX [nc_EffectiveArrivalTime] ON [dbo].[ivwApiUpdateRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.710 Done.
2022-04-13 14:59:57.710 Executing: ALTER INDEX [tbEulaProperty_PK] ON [dbo].[tbEulaProperty] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.750 Done.
2022-04-13 14:59:57.750 Executing: ALTER INDEX [nc1EulaProperty] ON [dbo].[tbEulaProperty] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.777 Done.
2022-04-13 14:59:57.777 Executing: ALTER INDEX [nc2EulaProperty] ON [dbo].[tbEulaProperty] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 14:59:57.843 Done.
2022-04-13 14:59:57.843 Executing: ALTER INDEX [PK__tbLocali__ED9531CAD798662D] ON [dbo].[tbLocalizedProperty] REORGANIZE
2022-04-13 15:00:08.603 Done.
2022-04-13 15:00:08.603 Executing: ALTER INDEX [PK__tbRevisi__15217053B7552F2A] ON [dbo].[tbRevisionInCategory] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:08.637 Done.
2022-04-13 15:00:08.637 Executing: ALTER INDEX [nc1RevisionInCategory] ON [dbo].[tbRevisionInCategory] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:08.673 Done.
2022-04-13 15:00:08.673 Executing: ALTER INDEX [PK__tbFile__67EC15CE8A94D90B] ON [dbo].[tbFile] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:08.710 Done.
2022-04-13 15:00:08.710 Executing: ALTER INDEX [nc1Category] ON [dbo].[tbCategory] REBUILD
2022-04-13 15:00:08.710 Done.
2022-04-13 15:00:08.710 Executing: ALTER INDEX [nc2tbXml] ON [dbo].[tbXml] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:08.967 Done.
2022-04-13 15:00:08.967 Executing: ALTER INDEX [UQ__tbRevisi__FFEE745013572FBA] ON [dbo].[tbRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:08.983 Done.
2022-04-13 15:00:08.983 Executing: ALTER INDEX [ncRevision_LocalUpdateID_RevisionNumber__IsLatestRevision] ON [dbo].[tbRevision] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.007 Done.
2022-04-13 15:00:09.007 Executing: ALTER INDEX [c0FileOnServer] ON [dbo].[tbFileOnServer] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.020 Done.
2022-04-13 15:00:09.020 Executing: ALTER INDEX [PK__tbFileOn__CEB6B0F6DEA5BF58] ON [dbo].[tbFileOnServer] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.037 Done.
2022-04-13 15:00:09.037 Executing: ALTER INDEX [UQ__tbUpdate__7A0CF3248A713C44] ON [dbo].[tbUpdate] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.057 Done.
2022-04-13 15:00:09.057 Executing: ALTER INDEX [c0DeploymentRevision] ON [dbo].[tbDeployment] REORGANIZE
2022-04-13 15:00:09.293 Done.
2022-04-13 15:00:09.293 Executing: ALTER INDEX [nc2DeploymentRevision] ON [dbo].[tbDeployment] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.337 Done.
2022-04-13 15:00:09.337 Executing: ALTER INDEX [nc5DeploymentRevision] ON [dbo].[tbDeployment] REORGANIZE
2022-04-13 15:00:09.497 Done.
2022-04-13 15:00:09.497 Executing: ALTER INDEX [nc6DeploymentRevision] ON [dbo].[tbDeployment] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.540 Done.
2022-04-13 15:00:09.540 Executing: ALTER INDEX [nc_RevisionID_TargetGroupID_ActionID] ON [dbo].[tbDeployment] REORGANIZE
2022-04-13 15:00:09.820 Done.
2022-04-13 15:00:09.820 Executing: ALTER INDEX [PK__tbDeadDe__5EF8D7176C4708F2] ON [dbo].[tbDeadDeployment] REBUILD
2022-04-13 15:00:09.823 Done.
2022-04-13 15:00:09.823 Executing: ALTER INDEX [PK__tbFlatte__15217053010D33F8] ON [dbo].[tbFlattenedRevisionInCategory] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.880 Done.
2022-04-13 15:00:09.880 Executing: ALTER INDEX [nc1FlattenedRevisionInCategory] ON [dbo].[tbFlattenedRevisionInCategory] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:09.900 Done.
2022-04-13 15:00:09.903 Executing: ALTER INDEX [PK__tbEventM__24626EC3227301B2] ON [dbo].[tbEventMessageTemplate] REBUILD
2022-04-13 15:00:09.907 Done.
2022-04-13 15:00:09.907 Executing: ALTER INDEX [PK__tbPreCom__5FF1DDB60E4CD459] ON [dbo].[tbPreComputedLocalizedProperty] REORGANIZE
2022-04-13 15:00:18.573 Done.
2022-04-13 15:00:18.573 Executing: ALTER INDEX [nc1PreComputedLocalizedProperty] ON [dbo].[tbPreComputedLocalizedProperty] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:18.960 Done.
2022-04-13 15:00:18.960 Executing: ALTER INDEX [PK__tbEventI__94C75A0739C22A4E] ON [dbo].[tbEventInstance] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:19.027 Done.
2022-04-13 15:00:19.027 Executing: ALTER INDEX [nc3EventInstanceConstraint] ON [dbo].[tbEventInstance] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:19.053 Done.
2022-04-13 15:00:19.053 Executing: ALTER INDEX [nc2EventInstance] ON [dbo].[tbEventInstance] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:19.063 Done.
2022-04-13 15:00:19.063 Executing: ALTER INDEX [ncEventInstance_ComputerID_EventNamespaceID_EventID] ON [dbo].[tbEventInstance] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:19.090 Done.
2022-04-13 15:00:19.090 Executing: ALTER INDEX [nc_EventNamespaceID_EventID] ON [dbo].[tbEventInstance] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:19.097 Done.
2022-04-13 15:00:19.097 Executing: ALTER INDEX [nc1RevisionLanguage] ON [dbo].[tbRevisionLanguage] REBUILD WITH (FILLFACTOR = 90)
2022-04-13 15:00:19.107 Done.
2022-04-13 15:00:19.110 Executing: ALTER INDEX [PK__tbPrecom__2DD8E6FD6241149C] ON [dbo].[tbPrecomputedCategoryLocalizedProperty] REBUILD
2022-04-13 15:00:19.113 Done.
2022-04-13 15:00:19.113 Executing: ALTER INDEX [nc2Property] ON [dbo].[tbProperty] REORGANIZE
2022-04-13 15:00:19.140 Done.
Estimated number of pages in fragmented indexes: 102530
Estimated number of pages freed: 12909
Updating all statistics.2022-04-13 15:00:19.170
Updating [dbo].[tbEventSource]
    [PK__tbEventS__DF51BBD6D6A69993] has been updated...
    [_WA_Sys_00000002_000AF8CF] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbUpdateClassificationInAutoDeploymentRule]
    [PK__tbUpdate__EF57E38A19F10EBD], update is not necessary...
    [_WA_Sys_00000002_019E3B86], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbEventNamespace]
    [PK__tbEventN__D26A6B34FCC29735] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbRevisionExtendedProperty]
    [cRevisionExtendedProperty], update is not necessary...
    [PK__tbRevisi__B4B1E3F016D22175], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbDcRollupStatus]
    [PK__tbDcRoll__3214EC077105E313], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbCategoryInAutoDeploymentRule]
    [PK__tbCatego__89359C8DF4025B99], update is not necessary...
    [_WA_Sys_00000002_038683F8], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbKBArticleForRevision]
    [PK__tbKBArti__41E15B739586BFE3] has been updated...
    [nc1KBArticleForRevision], update is not necessary...
    [tbKBArticleForRevision_RevisionID_AK] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbTargetGroupInAutoDeploymentRule]
    [PK__tbTarget__EF99A0ABB21CCA34], update is not necessary...
    [_WA_Sys_00000002_056ECC6A], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbMoreInfoURLForRevision]
    [PK__tbMoreIn__DF49EF3C638F0653], update is not necessary...
    [nc_RevisionID_ShortLanguage], update is not necessary...
    [_WA_Sys_00000004_05D8E0BE] has been updated...
    1 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [sys].[sqlagent_jobs]
    [sqlagent_jobs_clust], update is not necessary...
    [sqlagent_jobs_nc1_name], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbDeletedDynamicCategory]
    [PK__tbDelete__3214EC0743504EAB], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[sqlagent_jobsteps]
    [sqlagent_jobsteps_clust], update is not necessary...
    [sqlagent_jobsteps_nc1], update is not necessary...
    [sqlagent_jobsteps_nc2], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbSchemaVersion]
    [PK__tbSchema__3214EC27DAE12E5E] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [sys].[sqlagent_job_history]
    [sqlagent_job_history_clust], update is not necessary...
    [sqlagent_job_history_nc1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbSecurityBulletinForRevision]
    [PK__tbSecuri__2A32F464F3832071] has been updated...
    [nc1SecurityBulletinForRevision], update is not necessary...
    [tbSecurityBulletinForRevision_RevisionID_AK] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[sqlagent_jobsteps_logs]
    [sqlagent_jobsteps_logs_nc1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[plan_persist_query_text]
    [plan_persist_query_text_cidx], update is not necessary...
    [plan_persist_query_text_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbSchemaVersionHistory]
    [PK__tbSchema__3214EC279D8D69E4], update is not necessary...
    [_WA_Sys_00000002_0A338187], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbLocalizedPropertyForRevision]
    [PK__tbLocali__D4CFF3987CA3BCDC], update is not necessary...
    [nc1LocalizedPropertyID] has been updated...
    [_WA_Sys_00000003_0A9D95DB] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[plan_persist_query]
    [plan_persist_query_cidx], update is not necessary...
    [plan_persist_query_idx1], update is not necessary...
    [_WA_Sys_0000000B_0AD2A005], update is not necessary...
    [_WA_Sys_00000007_0AD2A005], update is not necessary...
    0 index(es)/statistic(s) have been updated, 4 did not require update.
 
Updating [dbo].[tbLocaleMap]
    [PK__tbLocale__AE84BA92DDB0A12D] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [sys].[plan_persist_plan]
    [plan_persist_plan_cidx], update is not necessary...
    [plan_persist_plan_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbFileForRevision]
    [PK__tbFileFo__42CF22AD880D1325] has been updated...
    [nc1FileForRevision], update is not necessary...
    [_WA_Sys_00000003_0C85DE4D] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[plan_persist_runtime_stats]
    [plan_persist_runtime_stats_cidx], update is not necessary...
    [plan_persist_runtime_stats_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbOSMap]
    [PK__tbOSMap__AEE3B0B5DD1C5790] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [sys].[plan_persist_runtime_stats_interval]
    [plan_persist_runtime_stats_interval_cidx], update is not necessary...
    [plan_persist_runtime_stats_interval_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbServerHealth]
    [PK__tbServer__DB06D1C03009743A], update is not necessary...
    [_WA_Sys_00000002_0E04126B] has been updated...
    [_WA_Sys_00000003_0E04126B] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[plan_persist_context_settings]
    [plan_persist_context_settings_cidx], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbDownstreamServerRollupConfiguration]
    [PK__tbDownst__3214EC27811DF1F5] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbFileHash]
    [PK__tbFileHa__67EC15CE6D7F5C88], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[plan_persist_query_hints]
    [plan_persist_query_hints_cidx], update is not necessary...
    [plan_persist_query_hints_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [sys].[plan_persist_query_template_parameterization]
    [plan_persist_query_template_parameterization_cidx], update is not necessary...
    [plan_persist_query_template_parameterization_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbProgramKeys]
    [PK__tbProgra__998876FC3880DEFD], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbEventRollupCounters]
    [PK__tbEventR__3214EC27DF7995EF] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbRevisionSupersedesUpdate]
    [PK__tbRevisi__43332583DDF5C093], update is not necessary...
    [nc1SupercededUpdateID], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [sys].[plan_persist_wait_stats]
    [plan_persist_wait_stats_cidx], update is not necessary...
    [plan_persist_wait_stats_idx1], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
 
Updating [dbo].[tbComputersThatNeedDetailedRollup]
    [cComputersThatNeedDetailedRollup] has been updated...
    [_WA_Sys_00000002_12C8C788] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbInstalledUpdateSufficientForPrerequisite]
    [PK__tbInstal__C3A16224D78C8EC9], update is not necessary...
    [nc1InstalledUpdateSufficientForPrerequisite], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
 
Updating [dbo].[tbConfigurationA]
    [PK__tbConfig__95AA539B8EE790E4], update is not necessary...
    [_WA_Sys_0000000E_13F1F5EB] has been updated...
    [_WA_Sys_00000018_13F1F5EB] has been updated...
    [_WA_Sys_0000000F_13F1F5EB] has been updated...
    [_WA_Sys_00000004_13F1F5EB] has been updated...
    4 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbBundleAtLeastOne]
    [tbBundleAtLeastOne_PK], update is not necessary...
    [nc1BundleAtLeastOne] has been updated...
    1 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbDriverTargetingGroup]
    [PK_DriverTargetingGroup_DriverTargetingID], update is not necessary...
    [AK_TargetGroupID], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbBundleAll]
    [tbBundleAll_PK] has been updated...
    [nc1BundleAll] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbDriverTargetingGroupPrerequisite]
    [PK_DriverTargetingGroupPrerequisite_DriverTargetingID_LocalUpdateID], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbPrerequisite]
    [PK__tbPrereq__25A953F9CA9A8E9C] has been updated...
    [nc1Prerequisite] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbDriver]
    [PK__tbDriver__258B78A97092C332], update is not necessary...
    [nc1Driver], update is not necessary...
    [nc2Driver], update is not necessary...
    [_WA_Sys_00000008_1AD3FDA4], update is not necessary...
    0 index(es)/statistic(s) have been updated, 4 did not require update.
 
Updating [dbo].[tbTargetedDriverHwid]
    [PK_tbTargetedDriverHwid_TargetGroupID_LocalUpdateID_HardwareID], update is not necessary...
    [IX_LocalUpdateID], update is not necessary...
    [_WA_Sys_00000003_1C5231C2], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbCompatiblePrinterProvider]
    [PK__tbCompat__DA62685FB41D4181], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbDriverClass]
    [PK__tbDriver__CB1927A08A47C413], update is not necessary...
    [_WA_Sys_00000002_1EA48E88] has been updated...
    1 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbDriverFeatureScore]
    [PK_tbDriverFeatureScore_OperatingSystem_FeatureScore_RevisionID_HardwareID], update is not necessary...
    [IX_RevisionID], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbTargetGroup]
    [PK__tbTarget__73CAF84DA05C146B] has been updated...
    [_WA_Sys_00000007_208CD6FA], update is not necessary...
    [_WA_Sys_00000001_208CD6FA], update is not necessary...
    [_WA_Sys_00000006_208CD6FA], update is not necessary...
    [_WA_Sys_00000002_208CD6FA], update is not necessary...
    1 index(es)/statistic(s) have been updated, 4 did not require update.
 
Updating [sys].[wpr_bucket_table]
    [wpr_bucket_clustered_idx], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbDistributionComputerHardwareId]
    [PK_tbDistributionComputerHardwareId_DistributionComputerHardwareId_RevisionID_HardwareID], update is not necessary...
    [IX_RevisionID], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbConfiguration]
    [PK__tbConfig__737584F7C43BB1AD] has been updated...
    [_WA_Sys_00000002_251C81ED] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbFlattenedTargetGroup]
    [cFlattenedTargetGroup] has been updated...
    [_WA_Sys_00000002_25518C17], update is not necessary...
    1 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbTargetComputerHardwareId]
    [PK_tbTargetComputerHardwareId_TargetComputerHardwareId_RevisionID_HardwareID], update is not necessary...
    [IX_RevisionID], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbPrerequisiteDependency]
    [PK__tbPrereq__4E62540B6C754374], update is not necessary...
    [nc1PrerequisiteDependency], update is not necessary...
    [nc2PrerequisiteDependency], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbImplicitCategory]
    [PK__tbImplic__D0AB8860BF46F2E4] has been updated...
    [_WA_Sys_00000002_2704CA5F] has been updated...
    [_WA_Sys_00000003_2704CA5F] has been updated...
    [_WA_Sys_00000004_2704CA5F] has been updated...
    4 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbTargetGroupType]
    [PK__tbTarget__59800DAA89DD3F23], update is not necessary...
    [_WA_Sys_00000002_282DF8C2], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbBundleDependency]
    [PK__tbBundle__40BEE6EB142CF854] has been updated...
    [nc1BundleDependency], update is not necessary...
    1 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbExpandedTargetInTargetGroup]
    [PK__tbExpand__017B08B6EB34A6FF] has been updated...
    [nc1ExpandedTargetInTargetGroup] has been updated...
    [_WA_Sys_00000003_2A164134] has been updated...
    3 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbUpdateStatusPerComputer]
    [cUpdateStatusPerComputer], update is not necessary...
    [nc3UpdateStatusPerComputer], update is not necessary...
    [nc2UpdateStatusPerComputer], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbCategoryInSubscription]
    [PK__tbCatego__D0AB88601B1C739B] has been updated...
    [_WA_Sys_00000001_2AD55B43] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbUpdateSummaryForAllComputers]
    [PK__tbUpdate__41FBF71B944D41D9] has been updated...
    [_WA_Sys_00000002_2C3393D0] has been updated...
    [_WA_Sys_00000007_2C3393D0] has been updated...
    [_WA_Sys_00000006_2C3393D0] has been updated...
    [_WA_Sys_00000005_2C3393D0] has been updated...
    [_WA_Sys_00000004_2C3393D0] has been updated...
    [_WA_Sys_00000003_2C3393D0] has been updated...
    7 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbLanguageInSubscription]
    [PK__tbLangua__709AE7C0E199A62C], update is not necessary...
    [_WA_Sys_00000001_2CBDA3B5], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbTargetInTargetGroup]
    [PK__tbTarget__017B08B65E7D85F8] has been updated...
    [nc1TargetInTargetGroup] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbEulaProperty]
    [tbEulaProperty_PK], update is not necessary...
    [nc1EulaProperty], update is not necessary...
    [nc2EulaProperty], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbSchedule]
    [PK__tbSchedu__0AFEF4FF505588C7] has been updated...
    [_WA_Sys_00000002_2F9A1060], update is not necessary...
    [_WA_Sys_00000006_2F9A1060] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbEulaAcceptance]
    [PK__tbEulaAc__51426B64EDE2F1AA], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbLocalizedProperty]
    [PK__tbLocali__ED9531CAD798662D] has been updated...
    [_WA_Sys_00000004_32AB8735] has been updated...
    [_WA_Sys_00000002_32AB8735] has been updated...
    [_WA_Sys_00000003_32AB8735] has been updated...
    4 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbEmailNotificationRecipient]
    [_WA_Sys_00000002_336AA144], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbComputerSummaryForMicrosoftUpdates]
    [PK__tbComput__2B1F0FB604F318EC] has been updated...
    [_WA_Sys_00000007_33D4B598] has been updated...
    [_WA_Sys_00000006_33D4B598] has been updated...
    [_WA_Sys_00000004_33D4B598] has been updated...
    [_WA_Sys_00000003_33D4B598] has been updated...
    [_WA_Sys_00000002_33D4B598] has been updated...
    [_WA_Sys_00000005_33D4B598] has been updated...
    7 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbRevisionInCategory]
    [PK__tbRevisi__15217053B7552F2A], update is not necessary...
    [nc1RevisionInCategory], update is not necessary...
    [_WA_Sys_00000003_345EC57D] has been updated...
    1 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbFile]
    [PK__tbFile__67EC15CE8A94D90B], update is not necessary...
    [_WA_Sys_0000000A_3493CFA7] has been updated...
    [_WA_Sys_00000009_3493CFA7] has been updated...
    [_WA_Sys_00000005_3493CFA7] has been updated...
    3 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbCategory]
    [PK__tbCatego__19093A2B07D353BA] has been updated...
    [nc1Category], update is not necessary...
    [_WA_Sys_00000003_373B3228] has been updated...
    [_WA_Sys_00000001_373B3228] has been updated...
    3 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbXml]
    [PK__tbXml__D14A66A9CC88A518] has been updated...
    [nc1tbXml] has been updated...
    [nc2tbXml], update is not necessary...
    [_WA_Sys_00000004_3A4CA8FD] has been updated...
    3 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbRequestedTargetGroup]
    [PK__tbReques__4AC8E77D35EB6745], update is not necessary...
    [AK_Name], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbRevision]
    [PK__tbRevisi__B4B1E3F16493AE88] has been updated...
    [UQ__tbRevisi__FFEE745013572FBA], update is not necessary...
    [ncRevision_LocalUpdateID_RevisionNumber__IsLatestRevision], update is not necessary...
    [_WA_Sys_0000000D_3BFFE745] has been updated...
    [_WA_Sys_00000003_3BFFE745] has been updated...
    [_WA_Sys_00000009_3BFFE745] has been updated...
    [_WA_Sys_00000005_3BFFE745] has been updated...
    [_WA_Sys_0000000C_3BFFE745] has been updated...
    [_WA_Sys_0000000E_3BFFE745] has been updated...
    [_WA_Sys_0000000A_3BFFE745] has been updated...
    8 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbRequestedTargetGroupsForTarget]
    [PK__tbReques__EFB381C179E466FA], update is not necessary...
    [nc1RequestedTargetGroupNamesForTarget], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbGroupAuthorization]
    [PK__tbGroupA__CD594A3193A4ADDD] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbDeletedComputer]
    [cDeletedComputer], update is not necessary...
    [_WA_Sys_00000002_3F466844], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbAuthorization]
    [PK__tbAuthor__7C10E5016D25CFAB] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.

 
Updating [dbo].[tbFileDownloadProgress]
    [c0FileDownloadProgress] has been updated...
    [PK__tbFileDo__FFEE7450BCA89139] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbSingletonData]
    [PK__tbSingle__3214EC270FE779F9] has been updated...
    [_WA_Sys_00000004_498EEC8D], update is not necessary...
    1 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbInventoryRule]
    [PK__tbInvent__110458C234910392] has been updated...
    1 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbInventoryClass]
    [PK__tbInvent__CB1927A04F7A1A51] has been updated...
    [UQ__tbInvent__737584F64ECCC7C5] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 

Updating [dbo].[tbNotificationEvent]
    [PK__tbNotifi__2BA9DFBC8A849DB6], update is not necessary...
    [_WA_Sys_00000004_725BF7F6], update is not necessary...
    [_WA_Sys_00000003_725BF7F6] has been updated...
    [_WA_Sys_00000002_725BF7F6], update is not necessary...
    1 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbDeadDeployment]
    [PK__tbDeadDe__5EF8D7176C4708F2], update is not necessary...
    [nc1DeadDeployment] has been updated...
    [nc2DeadDeployment] has been updated...
    [nc3DeadDeployment] has been updated...
    [_WA_Sys_00000012_72C60C4A] has been updated...
    [_WA_Sys_0000000F_72C60C4A] has been updated...
    [_WA_Sys_0000000D_72C60C4A] has been updated...
    [_WA_Sys_0000000C_72C60C4A] has been updated...
    7 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbChangeTracking]
    [c0ChangeTracking] has been updated...
    [PK__tbChange__DD60B210B23F024B] has been updated...
    2 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [dbo].[tbDynamicCategory]
    [PK_DynamicCategory], update is not necessary...
    [Unique_DynamicCategory_Name_Type], update is not necessary...
    [IX_dbDynamicInventoryItem_Name], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbFlattenedRevisionInCategory]
    [PK__tbFlatte__15217053010D33F8], update is not necessary...
    [nc1FlattenedRevisionInCategory], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [sys].[queue_messages_1977058079]
    [queue_clustered_index], update is not necessary...
    [queue_secondary_index], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbServerSyncResult]
    [PK__tbServer__54173E1BDBF94E93], update is not necessary...
    [nc1ServerSyncResult], update is not necessary...
    [nc2tbServerSyncResult], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbEventMessageTemplate]
    [PK__tbEventM__24626EC3227301B2], update is not necessary...
    [_WA_Sys_00000003_7869D707] has been updated...
    [_WA_Sys_00000002_7869D707] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[queue_messages_2009058193]
    [queue_clustered_index], update is not necessary...
    [queue_secondary_index], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update. 

 
Updating [dbo].[tbRevisionLanguage]
    [PK__tbRevisi__1F2266A96B0AB904] has been updated...
    [nc1RevisionLanguage], update is not necessary...
    [_WA_Sys_00000003_7A672E12] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[queue_messages_2041058307]
    [queue_clustered_index], update is not necessary...
    [queue_secondary_index], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbConfigurationB]
    [PK__tbConfig__95AA539B4EB6810C] has been updated...
    [_WA_Sys_00000003_7B264821] has been updated...
    [_WA_Sys_00000002_7B264821] has been updated...
    3 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [sys].[filestream_tombstone_2073058421]
    [FSTSClusIdx], update is not necessary...
    [FSTSNCIdx], update is not necessary...
    0 index(es)/statistic(s) have been updated, 2 did not require update.
 
Updating [dbo].[tbPrecomputedCategoryLocalizedProperty]
    [PK__tbPrecom__2DD8E6FD6241149C], update is not necessary...
    [_WA_Sys_00000002_7BE56230] has been updated...
    1 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [sys].[syscommittab]
    [ci_commit_ts], update is not necessary...
    [si_xdes_id], update is not necessary...
    [si_commit_time_ts], update is not necessary...
    0 index(es)/statistic(s) have been updated, 3 did not require update.
 
Updating [dbo].[tbEvent]
    [PK__tbEvent__24626EC3ACD99138] has been updated...
    [_WA_Sys_00000002_7D2E8C24] has been updated...
    [_WA_Sys_00000004_7D2E8C24], update is not necessary...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbProperty]
    [PK__tbProper__B4B1E3F1ED122F5D] has been updated...
    [nc1Property] has been updated...
    [nc2Property] has been updated...
    [_WA_Sys_00000005_7D439ABD] has been updated...
    [_WA_Sys_00000006_7D439ABD] has been updated...
    [_WA_Sys_0000000B_7D439ABD] has been updated...
    [_WA_Sys_00000013_7D439ABD] has been updated...
    [_WA_Sys_00000015_7D439ABD] has been updated...
    [_WA_Sys_00000012_7D439ABD] has been updated...
    [_WA_Sys_00000004_7D439ABD] has been updated...
    [_WA_Sys_00000003_7D439ABD] has been updated...
    [_WA_Sys_00000002_7D439ABD] has been updated...
    12 index(es)/statistic(s) have been updated, 0 did not require update.
 
Updating [sys].[filetable_updates_2105058535]
    [FFtUpdateIdx], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbMapping_Target_DynamicCategory]
    [PK__tbMappin__90B4D91DA5AA9E72], update is not necessary...
    0 index(es)/statistic(s) have been updated, 1 did not require update.
 
Updating [dbo].[tbAutoDeploymentRule]
    [PK__tbAutoDe__3214EC27AF232B5C], update is not necessary...
    [_WA_Sys_00000002_7DCDAAA2] has been updated...
    [_WA_Sys_00000003_7DCDAAA2] has been updated...
    2 index(es)/statistic(s) have been updated, 1 did not require update.
 
Statistics for all tables have been updated.
Done updating statistics.2022-04-13 15:00:23.490

Completion time: 2022-04-13T15:00:23.5018971+05:30

3 thoughts on “Quickly Reindex WSUS Database using T-SQL Script”

  1. Hi Guys,
    For people visiting this blog in future. Here are the steps to connect SSMS to WID.

    1) Install SSMS. Download latest version from Micorosoft.
    2) Laucnh SSMS with admin priviliges (as Administrator).
    3) The connection string is np:\\.\pipe\MICROSOFT##WID\tsql\query
    4) Follow the guide provided by Prajwaldesai.

    Reply
  2. Additionally, I would like to mention that on a standalone WSUS server SQL studio is still useful but you need to know how to connect to the Windows Internal Database (WID).

    Reply
  3. Dear Prajwal,
    Thank you for the beautiful detailed expenation about how to maintain the WSUS DB using a script throuh SQL Studio. I’m running is on a standalone server and therefore I cannot use this. I need to make use of the sqlcmd utility. The installation needs the odbc drivers but after installing these it will install. What I miss is some more expleantion about how to apply this T-SQL script to the Windows Internal Database.

    Reply

Leave a Comment