Share via


Product Configuration Performance : Caching

This post is part of the series of posts explaining performance improvements introduced in Constraint-Based Product Configuration in Microsoft Dynamics AX 2012 R3 CU8.

 

Motivation

The product configuration model is persisted in a normalized data model in the database. As a result of this, this tables in the data models will need to be queried in order to obtain all the needed information to load a product configuration model. The parent-child relation between components and subcomponents require that this is done in a recursive manner, thus it is not possible to retrieve all the information in a single select statement. For large models the traversal of the data model is a time consuming operation. However we are not just traversing the model, we are also constructing an XML representation of the model that is relevant for a given configuration session. If the model is not changing, all the end users are basically paying a performance penalty of having the same XML generated over and over again. This is why caching is has been introduced.

 

The setup

Runtime caching is disable by default, so you need to perform a contience decision if you would like to enable it. The parameter of enabling runtime caching is located in the Product Information management setup form.

 

 

Working with the cache

Once enabled, cached elements will be loaded with the latest cached value, if you change the value of a cached element in the model details form, be sure to clear the cache before loading the model.

 

It is not recommended to have the cache enabled during development of configuration models, because the cache will need to be cleared manually by pressing the "Clear cache" button i.e. the cache is not cleared automatically when you update the model.

 

 

 

The clearing of the cache happens on a per model basis, so even if two models are using the same components, clearing of the cache should be performed for both models independently.

 

The implementation

The runtime cache manager class is to be used for all interaction with the runtime cache. Both classes and record values can be cached see list be below for currently cached elements.

 

Current cached elements

  • Tables (records)
    • The entire model definition
  • Classes
    • RuntimeAttributeType instances used for system defined table constraints

 

Keys to the cache

  • Product configuration model record ID
  • Language ID
  • Price model record ID
  • Price model currency

 

The above elements define what is used as the identify an entry in the cache. If a request to load a configuration model does not match on all the key elements available in the cache, then the XML will have to generated for the specific request.