# DataLink – Order of Execution

I’d be curious to know how Quantrix figures the order in which to execute DataLinks.

I have an external datalink that feeds a reference matrix; then another matrix uses lookup formulas to pull data from the reference matrix; then another datalink copies the calculated values to an export matrix.

You can see that in this case the order of datalinks is important; the import first should come first, then the export.

Quantrix calculates the “depth” of the link to determine the order. The “shallowest” links are updated first. Links with the same depth are not guaranteed any particular update order. Links which refer to external sources (e.g. JDBC, CSV, XML) have a depth of 0. Internal links (matrix links) have a depth of 1 + the depth of the link (if any) the source matrix has.

In your case, this algorithm should work. However, if you had a situation where (for instance):

– matrix b was datalinked to matrix a

– matrix c calculated off of matrix b

– matrix d is datalinked to matrix c

you wouldn’t be guaranteed the right update order because both matrix D and matrix B have a depth of 1

In other words, the calculation step breaks the “dependency tree” of the datalinks.

Please feel free to post further questions.

Cheers,

pete