1. A computer implemented method comprising: receiving, via an application programming interface (API) of a calculation engine including a model optimizer having an optimizer framework, data comprising at least one optimization rule, the calculation engine executing on a calculation engine layer that interacts with a physical table pool and a logical layer, the physical table pool comprising physical tables containing data to be queried, and the logical layer defining a logical metamodel joining at least a portion of the physical tables in the physical table pool; registering, by the calculation engine, the at least one optimization rule for execution by a rules engine of the optimizer framework, wherein the optimizer framework assigns cost functions to at least a portion of optimization rules, the cost functions being used to determine when to execute a particular optimization rule; receiving, by the calculation engine, subsequently each query; generating, by the calculation engine, an initial data flow graph comprising a plurality of nodes specifying operations for executing the query; optimizing, by the calculation engine, the initial data flow graph using the rules engine, wherein at least one rule is applied to only a single node of the initial data flow graph, wherein a first subset of the operations are executed directly by the calculation engine and a second, different subset of the operations are transformed into a set of logical database execution plans, wherein each rule of the rules engine identifies one to N predecessors of corresponding start node from which optimization can be initiated, wherein N is an integer number, wherein said each rule specifies read and write operations to perform on corresponding nodes; and initiating executing of the query using the optimized data flow graph.