SharePoint site collection backup or SQL database backup for SharePoint databases are not recommended to schedule at midnight as it causes skipping of database statistics update.
Microsoft SharePoint is scheduled to run database statistics update (proc_updatestatistics) for every database at midnight.
When we run database backup either full or incremental, it enables skipping for statistics update.
When you check with below query, it would give you the result as updating statistics but it would not actually do.
- EXECUTE sp_msforeachdb
- 'USE [?];
- IF DB_NAME() NOT IN(''master'',''msdb'',''tempdb'',''model'')
- begin
- SELECT ''CHECKING STATS FOR '' + DB_NAME() AS ''DATABASE NAME''
- SELECT OBJECT_NAME(A.OBJECT_ID) AS ''TABLE NAME''
- , A.NAME AS ''INDEX NAME''
- , STATS_DATE(A.OBJECT_ID,A.INDEX_ID) AS ''STATS LAST UPDATED''
- FROM SYS.INDEXES A
- JOIN SYS.OBJECTS B
- ON B.OBJECT_ID = A.OBJECT_ID
- WHERE B.IS_MS_SHIPPED = 0
- ORDER BY OBJECT_NAME(A.OBJECT_ID),A.INDEX_ID
- end'
To overcome this issue, create a SQL agent job that runs at least daily and runs the following script.
- EXECUTE sp_msforeachdb
- 'USE [?];
- IF DB_NAME() NOT IN(''master'',''msdb'',''tempdb'',''model'')
- begin
- print ''updating statistics in database ==> '' + db_name()
- if exists (select 1 from sys.objects where name = ''proc_updatestatistics'')
- begin
- print ''updating statistics via proc_updatestatistics''
- exec proc_updatestatistics
- end
- else
- begin
- print ''updating statistics via sp_updatestats''
- exec sp_updatestats
- end
- end'
To repair the same with out of box features at SharePoint Central Admin:
- Verify that the user account that is performing this procedure is a member of the Farm Administrators group.
- On the Central Administration Home page, click Monitoring.
- On the Monitoring page, in the Health Analyzer section, click Review rule definitions.
- On the Health Analyzer Rule Definitions – All Rules page, in the Category: Performance section, click the name of the rule.
- In the Health Analyzer Rule Definitions dialog box, click Edit Item.
- Select the Repair Automatically check box, and then click Save.