In this article:
Article number: KB000014
Related blocks:
When creating and using dictionaries in Foresight Analytics Platform, mistakes are often made, which may cause incorrect application work and use of the platform.
A dictionary is based on the table that contains the most records. Only some records are included into the dictionary as its elements.
Thus, when a dictionary is created, all table records are extracted to the client workstation. Next, the records are filtered either using a custom filter or by the developer who is creating a dictionary. This happens quite often when a single table stores data for several dictionaries or the data that differs by value of some field.
Extracting a large number of records takes much time. The problem becomes more serious when the system lacks operating memory. Filtering a large number of records is also time-consuming. Both factors lead to significant increase in time required to open a dictionary.
Creating a dictionary based on the query that filters only the required records from the table. The query can be a parametric one and it can be controlled from the dictionary. So you can use a single request for multiple dictionaries. Filtering data on the server can greatly speed up building a dictionary.
Using filter in a dictionary instead of filtering data on the request level.
There is a parametric dictionary. A dictionary should include only the elements with value of a certain field (attribute) equal to the parameter's value. In this case a filter is often applied for the dictionary: value of a field or an attribute should match the parameter's value. When a dimension contains a large number of elements, checking the condition takes much time because an expression in Fore is to be calculated for each record of the source table (request).
Building a dictionary based on a query is similar to the procedure described above. The only difference in this case is that the dictionary parameter is to control the query parameter.
It is recommended to use a filter in the dictionary only for unusual filtering methods. In other cases it is better to filter values on the level of database query.
Platform kernel caches dictionaries including parametric ones. If a dictionary of the application system with a large number of elements (attributes) opens many times with various parameters' values, this may cause significant consumption of memory required to store cache. If parameters of the Data type are used to manage a dictionary, parameter values should be passed without time component (time component value is to be set to default value 00:00).
This should be taken into account when developing application systems. If you need to constantly reopen dictionaries, it is recommended to clear cache of corresponding object or the entire repository after closing a dictionary. Platform kernel includes various tools for cache management:
IMetabase.Cache - access to repository cache. Using methods available for repository cache, you can clear cached data of either particular objects or the entire repository. You can get cached data of particular objects.
IMetabaseObject.FlushInstance and IMetabaseObject.FlushInstances - methods that allow for clearing cache of a particular repository object.
See also:
Developers Knowledge Base | IMetabase.Cache | IMetabaseObject.FlushInstance | IMetabaseObject.FlushInstances