I need to count the relationships for some items types, like for example the number of "Validated By" traces for a Requirement.
1) One way to do that is via a dynamic calculation: for example, "Trace Count - Validated By" is defined as isEmpty( RelCount( "Validated By" ) , 0 ).
2) The other way is to keep the field as a normal input integer (no calculation), but define a rule on the relationship field "Validated By" that runs a trigger script like "count.js".
Which solution is better from a performance standpoint?
- On one hand, having the dynamic calculation means it's performed every time the item is accessed. Changing the computation to static is not a solution since I need the number as soon as it changes.
- On the other hand, I've noticed that rule triggers are run every time the item is edited, no matter which fields are edited. I even suspect that all the rules are run for all relationship fields, but I'm not sure of that (and no time to investigate further). For items in a document that is saved as a whole, that could mean tens of trigger calls for each edit.
I've implemented both and don't perceive any performance impact. However, I'd like to get some feedback from the community and PTC before going further.