Skip to main content

Legacy and LegacyOptimized Calculation Engines

  • 4 minutes to read

Legacy is the originally developed data engine that can be used if a data-source contains less than 100,000 rows. The engine is not optimized for summary and aggregate calculations. Instead, Legacy is designed to operate with a dozen fields in the row area that contain mostly unique values.

The LegacyOptimized engine is available in v17.1 and higher. The engine supports the Legacy engine’s features, inherited from the legacy API, and increases data processing speed by up to 30 times. In v17.2 and higher, this mode can utilize multi-core processors for data operations: the control splits bound records into bulks and processes them in parallel threads, and the data processing speed increases proportionally to the number of CPU cores. This mode also allows you to restore a layout configured in Legacy mode. In v18.2 and higher, LegacyOptimized is the default engine.

To switch to the LegacyOptimized engine, set the PivotGridOptionsData.DataProcessingEngine property to DataProcessingEngine.LegacyOptimized:

pivotGridControl1.OptionsData.DataProcessingEngine = PivotDataProcessingEngine.LegacyOptimized;

Performance Comparison Across Versions

Microsoft’s Contoso Database is used to measure Pivot Grid’s performance for different versions. The test query returns 3.4M records. We requested values from ProductName, ProductSubcategoryName, ProductCategoryName, and DateKey dimensions, and SalesAmount, and SalesQuantity measures. The Pivot Grid displays both SalesAmount and SalesQuantity fields, groups data by ProductName, ProductSubcategoryName, ProductCategoryName field values and implements the Year → Quarter → Month hierarchy from the DateKey source field.

performance-comparison

As you can see in the above table, the LegacyOptimized engine (available in v17.1 and higher) increases data processing speed in comparison to the Legacy engine (v16.2).

Data Binding

The Legacy and LegacyOptimized modes support bound and unbound fields:

  • Bound fields retrieve data from the Pivot Grid’s underlying data source.
  • Unbound fields get data by evaluating an expression or handling an event. You can sort, group, and filter unbound fields like bound fields.

Data Processing

LegacyOptimized and Legacy modes use an API that is not supported in Optimized mode.

LegacyOptimized performs different data-related features in the following cases:

  1. Data Sorting and Grouping.

    The Legacy engine aggregates data after sorting at the data source level. The Pivot Grid raises the CustomFieldSort event to compare different data rows and calls the CustomGroupInterval event for each data source row.

    The LegacyOptimized engine sorts aggregated data. The LegacyOptimized engine raises the CustomFieldSort event to compare the resulting data groups and the CustomGroupInterval event for unique field values only.

  2. The default summary values specified by the SummaryType property are calculated without converting values.

    The Legacy engine converts all values to decimal and calculates summary values.

    In LegacyOptimized mode, the PivotGridFieldBase.SummaryType property specifies the default summary values and the LegacyOptimized engine performs calculations without converting values.

  3. Calculated Fields are processed for fields with incorrect FieldName values.

    The Legacy engine checks the FieldName and UnboundFieldName values of calculated fields before processing. If names match the name of any data source column, the field is ‘bound’ and data is loaded from the data source. The LegacyOptimized engine does not verify field names and calculates all fields with any UnboundType property value except for Bound.

  4. The IEnumerable.GetEnumerator method is used to read data from a data source.

    The Legacy engine uses the IList.Item[Int32] property to read all data. The new LegacyOptimized engine uses the IList.Item[Int32] property to get values from specific data source rows, and uses the IEnumerable.GetEnumerator method to read data from the entire data source to improve performance.

  5. Unbound expressions are compiled before processing.

    The Legacy engine processes unbound expressions for each row in the data source and can parse string values to get DateTime or numbers.

    The LegacyOptimized engine compiles unbound expressions once before data is processed. This technique improves processing time, but has restrictions for the type of supplied data. For example, you need to use ToDateTime, ToInt, ToDouble, and ToDecimal functions to parse string values.

Limitations

For information about Legacy and Legacy Optimized mode restrictions, refer to the following article: In-Memory Mode Limitations.