View Optimisation when using Fetch/LookUp
- Judy_WuOP
While doing view optimisation we noticed below behaviour:
Details of the daml template setup
TemplateT1has-
signatory
A -
observer
B -
key by
A -
maintainer
A -
choice
C1controllerAdo two things: -
fetch some contract
-
exercise some other choice
C2on TemplateT2
Inside the Trees: I have 2 child views of FetchAction and ExerciseAction
C2
Both view has- Confirmee:
A - No Informee
I wonder why there’s no informee for both child views? shouldn’t
Bbe the informee?
Even if I explicitly addBas observer to choiceC1, I still see no informee for both view
Can someone help to demistify this? -
- Judy_Wu 1
After some digging with @WallaceKelly and information provided by @Andreas_Lochbihler (Big thank you to both!)
we realised that the reason of above behaviour is due to
fetch,fetchByKeyandlookUpByKeynot inheriting observer from the parent choice (more details can be viewed here)This will cause one or more not mergeable child views in a choice if we have at least one observer in the parent template and within the choice there’s one or more actions using
fetch,fetchByKeyandlookUpByKey.
To optimize for performance, as suggested by @Andreas_Lochbihler , what we can do is to wrap the fetches to a non-consuming choice and configure choice observers/controllers explicitly as we see fit.
However, the same cannot be done forlookUpByKey