The execution plan is useful. You can add indexās on at anytime during the day, I dont bother with downtime as the system will build and just not use it until itās done. You may need to clear your query cache. Which Version of SQL are you on and are you using the Legacy Cardinal Estimator?
I did a writeup and a thread somewhere that goes though some of the settings to apply to SQL to help with performace.
FYI below is what we use as a weekly main script. Itās basically the default MS SQL Server 2005 one (still the best scripti for the job
) passed though AI for any improvements.
USE Epicor10Live; --change this to you epicor database
SET NOCOUNT ON;
SET XACT_ABORT ON;
RAISERROR(ā=========================================ā,0,1) WITH NOWAIT;
RAISERROR(āWEEKEND MAINTENANCE STARTEDā,0,1) WITH NOWAIT;
RAISERROR(ā=========================================ā,0,1) WITH NOWAIT;
ā CHECKDB (PHYSICAL ONLY)
RAISERROR(āRunning CHECKDB (PHYSICAL_ONLY)ā¦ā,0,1) WITH NOWAIT;
āDBCC CHECKDB WITH PHYSICAL_ONLY, NO_INFOMSGS;
RAISERROR(āCHECKDB complete.ā,0,1) WITH NOWAIT;
ā Capture Fragmentation (>10%)
IF OBJECT_ID(ātempdb..#fragā) IS NOT NULL DROP TABLE #frag;
SELECT
OBJECT_SCHEMA_NAME(ps.object_id) AS SchemaName,
OBJECT_NAME(ps.object_id) AS TableName,
i.name AS IndexName,
ps.avg_fragmentation_in_percent,
ps.page_count
INTO #frag
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, āLIMITEDā) ps
JOIN sys.indexes i
ON ps.object_id = i.object_id
AND ps.index_id = i.index_id
WHERE
ps.index_id > 0
AND ps.page_count > 1000
AND ps.avg_fragmentation_in_percent > 10;
ā Rebuild
DECLARE @Schema sysname,
@Table sysname,
@Index sysname,
@sql nvarchar(max);
DECLARE rebuild_cursor CURSOR FOR
SELECT SchemaName, TableName, IndexName
FROM #frag;
OPEN rebuild_cursor;
FETCH NEXT FROM rebuild_cursor INTO @Schema, @Table, @Index;
WHILE @@FETCH_STATUS = 0
BEGIN
RAISERROR(āRebuilding %s.%s (%s)ā¦ā,0,1,@Schema,@Table,@Index) WITH NOWAIT;
SET @sql = '
ALTER INDEX [' + @Index + '] ON [' + @Schema + '].[' + @Table + ']
REBUILD WITH (SORT_IN_TEMPDB = ON, MAXDOP = 8);
';
EXEC(@sql);
FETCH NEXT FROM rebuild_cursor INTO @Schema, @Table, @Index;
END
CLOSE rebuild_cursor;
DEALLOCATE rebuild_cursor;
RAISERROR(āIndex rebuild phase complete.ā,0,1) WITH NOWAIT;
ā FULLSCAN Statistics
RAISERROR(āUpdating statistics WITH FULLSCANā¦ā,0,1) WITH NOWAIT;
DECLARE @tbl nvarchar(500);
DECLARE stats_cursor CURSOR FOR
SELECT QUOTENAME(SCHEMA_NAME(schema_id)) + ā.ā + QUOTENAME(name)
FROM sys.tables
WHERE is_ms_shipped = 0;
OPEN stats_cursor;
FETCH NEXT FROM stats_cursor INTO @tbl;
WHILE @@FETCH_STATUS = 0
BEGIN
RAISERROR(āUpdating stats on %sā¦ā,0,1,@tbl) WITH NOWAIT;
EXEC(āUPDATE STATISTICS ā + @tbl + ā WITH FULLSCAN;ā);
FETCH NEXT FROM stats_cursor INTO @tbl;
END
CLOSE stats_cursor;
DEALLOCATE stats_cursor;
RAISERROR(ā=========================================ā,0,1) WITH NOWAIT;
RAISERROR(āWEEKEND MAINTENANCE COMPLETEā,0,1) WITH NOWAIT;
RAISERROR(ā=========================================ā,0,1) WITH NOWAIT;