Calculation in Analytics

The Pricefx Analytics Calculation logics use specific contexts to determine when and how often logic elements execute during a Data Load. Understanding these contexts is essential for optimizing performance and ensuring data is processed correctly across rows and summaries.

Calculation Context

Calculation Context (also referred to as Element Groups) define the execution phase of a logic element. There are three different types:

  • Initialization – The logic runs once for all Init level elements at the start of the process. This context is typically used for setup tasks or fetching global parameters.

  • Row – The logic runs the Row level elements for each row in the dataset. These elements are meant to be inputs and outputs, reading and writing values of a row.

  • Summary – The logic runs once more for all Summary elements after all rows have been processed. This is used for final aggregations or post-processing tasks.

Execution Logic and Circuit Breakers

To optimize performance and not waste time in the calculation, Pricefx employs a circuit breaker mechanism for Row level logic. The system may skip all row level logic runs under specific conditions to reduce processing overhead.

Row Logic Skip Conditions

The system will only run the Initialization and Summary phases and skip the Row phase if:

  1. In the Data Load configuration, specifically the Calculation tab, you did not select anything in Formula Outputs → Target Fields.

  2. There is no Row element matching the selected outputs.

If your logic relies on Row level calculations to update data, ensure that the target fields are correctly mapped in the Calculation tab of the Data Load.

Database Connection Management

For long-running calculation Data Loads, the system maintains an open connection to the Pricefx (Price Setting) database for the entire duration of the query execution. In environments using PostgreSQL (PG), these jobs may be subject to the idle_in_transaction_session_timeout setting.

If a calculation Data Load exceeds this timeout (typically set to 2 hours in standard configurations), the connection may be terminated with a FATAL: terminating connection due to idle-in-transaction timeout error. If you encounter this error in Administration > Logs > Jobs, contact Pricefx Support to discuss adjusting the timeout or optimizing the calculation logic to prevent table bloat.

Additionally, the system enforces a global calculation timeout (defaulting to 48 hours). If a job exceeds this limit, it is terminated to prevent excessive resource consumption. This limit can be adjusted by Pricefx Support using the PA_CALCULATION_TIMEOUT_OVERRIDE_IN_SECS configuration property.

Transaction Management Fix

To prevent timeout errors in long-running calculations, a fix is available that manages the database transaction state more effectively. This fix is controlled by the commitTransactionBeforeDataLoad Advanced Configuration Option.

For more information see the Advanced Configuration Options.

Summary of Execution Flow

Phase

Context

Frequency

Purpose

1

Initialization

Once

Global setup and variable initialization.

2

Row

Per Row

Reading and writing values for individual records.

3

Summary

Once

Final calculations and data aggregation.

AnalyticsCalcLogicDetails.png
Calculation Logic Details

This execution flow applies to non-distributed Analytics Calculation Data Loads. For distributed calculations, the logic may be partitioned across multiple nodes.