-
Notifications
You must be signed in to change notification settings - Fork 5
Description
It appears that when you use domain:get-model-field across invokes, the caching never is used and results in expensive traversal because of // path expression which must visit every node matching the path and the predicate. The idea is to precache the entire model once and use a map:lookup which will significantly improve performance when multiple calls are made to cached functions.
A list of functions that can take advantage of pre-optimized caching
domain:get-model-unique-constraint-fields
domain:get-model-uniqueKey-constraint-fields
domain:get-model-key-field
domain:get-model-keyLabel-field
domain:get-model-identity-field
domain:get-model-field
An example of precaching is as follows:
declare function domain:precache-model($model as element(domain:model)) {
let $model-name := $model/@name
return
$model//(domain:element|domain:attribute|domain:container) ! (
domain:set-identity-cache(fn:concat($model-name || ":field:" || ./@name),.),
domain:set-identity-cache(fn:concat($model-name || ":field:" || ./@keyname),.),
domain:set-identity-cache(fn:concat($model-name || ":field:" || ./@key),.)
)
};