Continuing the discussion from Performance issue in form with many repeat entries:
I’ve started a separate thread as the original discussion was moving towards a discussion of the data graph.
As @baschir-loud-bluff mentioned in the original thread, Computation Rules can lead to performance issues as they need to be checked on loading and recalculated with every value change.
There are a number of Computation Rules modeled in the Groups “Summen” and “SummenZN” which calculate as helper fields. For example, Gesamt_ESF, Gesamt_EFRE, Gesamt_LM and Gesamt_EMFAF are calculate for each line of the repeat “Summen” so that the result of one of these fields can be shown in the Field “Gesamt”.
The calculations carried out in these Computation Rules are, with a few exceptions very similar. As a result, you may be able to remove a number of these Computation Rules.
I tried to re-model the Computation Rules “Computation_Gesamt” so that the rules and fields “Gesmat_ESF”, “Gesamt_EFRE”, “Gesamt_LM”, “Gesamt_EMFAF” and “Strukturfond” could be removed from “Summen”.
Common Precondition
GroupFilled(RuleGroup)
And
AllFieldsFilled(Kostenart, /Bedingungen/Strukturfond)
and
AtLeastOneFieldFilled(../Beleg*/Betraege/GezahlterBetrag)
Precondition 1 for the “normal situation”. If you need to explicitly state the accepted values of the Kostenart, you can easily change the operator here.
([/Bedingungen/Strukturfond] == "ESF"
And NoFieldValueIncludedInValueList(Kostenart In "5668", "5788"))
Or ([/Bedingungen/Strukturfond] == "EFRE"
And NoFieldValueIncludedInValueList(Kostenart In "7017", "4523"))
Or ([/Bedingungen/Strukturfond] == "LM"
And NoFieldValueIncludedInValueList(Kostenart In "7023"))
Or ([/Bedingungen/Strukturfond] == "EMFAF")
Calculation 1
Sum(../Beleg*/Betraege/GezahlterBetrag Having [../Beleg/Kostenart] == [$Kostenart] )
This uses the $-Operator to iterate through the Konstenart selected for each line in “Summe”. You can find more information in the documentation or in the Kernel Language Tutorial (Step 3).
The exceptions to this calculation can then be added individually. I only noticed 5 exceptions, for example:
Precondition 2
[/Bedingungen/Strukturfond] == "ESF"
And [Kostenart] == "5668"
And [/Bedingungen/RestkostenpauschaleNichtRelevant] == False
Calculation 2
RoundDown({Sum(/Belegliste/Beleg*/Betraege/GezahlterBetrag Having [/Belegliste/Beleg/Kostenart->RTKP_PAUSCHALE]
== "JA") * [/Bedingungen/Restkostenpauschale] / 100}, 2)
As this Computation Rule has 6 entries in the Computation Table, I also feel that it is easier to understand than the current situation.
I believe this approach can be applied to most of the calculations in “Summe” and “SummeNZ” so that you reduce the number of computed fields by about 20 fields per line in the repetition.
It’s very difficult to reverse engineer all these computations in your document model for you, but I strongly believe that you can reduce the number of helper fields. If you can go through them and move calculations from helper fields to a single field for the end result, this should lead to better performance.