How to: Optimize a Model Store for Runtime

Important

This content is archived and is not being updated. For the latest documentation, see Microsoft Dynamics 365 product documentation. For the latest release plans, see Dynamics 365 and Microsoft Power Platform release plans.

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic describes how to optimize a model store after changes have been made to the models that it contains. The optimization commands perform a series of steps that optimize the model store for run-time performance. As part of this process, the database that contains the model store is re-indexed and has a DBCC SHRINKDATABASE command performed on it.

Important

By default, the optimization steps that this topic describes are performed when a model is installed for the first time. These steps are also performed if the number of elements in a model increases by more than 50 percent when the model is reimported, or when the model store that contains the model is imported.

We recommend that you manually optimize a model store after you have completed significant deletions, insertions, or updates.

Important

In versions of Microsoft Dynamics AX 2012 prior to Microsoft Dynamics AX 2012 R2, the model store tables are stored in the same database as the business data. If your environment contains a large combined business and model store database, we recommend that you avoid running the Microsoft Dynamics AX optimization command. Instead, we suggest that you create a Microsoft SQL Server maintenance plan that reindexes the database.

You can use either Windows PowerShell cmdlets or the AXUtil command-line utility to perform this task.

Drain client connections and validate permissions

  1. Drain the client connections that are connected to the Application Object Server (AOS) instance that you are working with. For more information, see Drain users from an AOS.

  2. Validate that you have appropriate permissions to work with the model store:

    • Administrative permissions on the local computer

    • System Administrator rights in Microsoft Dynamics AX

    • In Microsoft SQL Server:

      • Membership in the Securityadmin server role on the SQL Server instance

      • Membership in the db_owner role in the Microsoft Dynamics AX database

Optimize a model store (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.

  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.

    Optimize-AXModelStore 
    

    For more information, see Optimize-AXModelStore.

Optimize a model store (AXUtil)

  1. On the Start menu, click Command prompt.

  2. Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.

  3. At the command prompt, type the following command, and then press ENTER.

    axutil optimize
    

See also

Models, Layers, and the Model Store

AxUtil and Windows PowerShell Commands for Deploying Models

Administering Microsoft Dynamics AX by using Windows PowerShell

Windows PowerShell for Microsoft Dynamics AX

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.