I am facing some performance issues opening "big" databases due to an (unexpected for me) argument evaluation during function composition. Is this a normal behavior ?
declare variable $db := db:open("MyBigDataBase");
declare function local:elts($db){$db//element()};
declare function local:compose($f1 as function(*), $f2 as function(*)) as function(*){ function($a) { $f1($f2($a)) }};
declare function local:count_elt($db) {count(local:elts($db))};
prof:time(local:count_elt($db)),
prof:time(count(local:elts($db))),
prof:time(local:compose(count#1,local:elts#1) ($db))