After downloading the Dynamics 365 for Finance and Operations 8.1 PU 20 VHD from LCS, I went about optimizing its performance.  So far I used it a bit without doing a full compile and it seems to run less than 15 GB of RAM, although I have allocated much more.  Some low hanging fruit is defragmenting the indexes in the databases.

Check the index fragmentation (optional, interesting)

1. Open SQL Server Management Studio as Administrator

2. Connect to the local instance.  You can use a period in the server name.

3. Run the following query against the AxDB.  In the VM I downloaded over one thousand indexes had a fragmentation higher than 30%.

-- List fragmented indexes in current DB
SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName,
indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent,
'ALTER INDEX [' + ind.name + '] ON [dbo].[' + OBJECT_NAME(ind.OBJECT_ID) + '] REBUILD' AS [Rebuild Script]
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30
ORDER BY indexstats.avg_fragmentation_in_percent DESC

Defragment the indexes

1. Download Ola Hallengren’s IndexOptimize stored procedure.

2. Run the MaintenanceSolution.sql while connected to master db.  This will “install” the stored procedures in the environment.

3. Run the following script

EXECUTE master.dbo.IndexOptimize
@Databases = 'ALL_DATABASES',
@FragmentationLow = NULL,
@FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 25,
@LogToTable = 'N',
@UpdateStatistics = 'ALL',
@OnlyModifiedStatistics = 'Y'

The update will take some time, and will significantly speed up the performance of D365FO.