Hi Jean-Marc,
It's not that trivial to optimize your query, but I'd like to let you know that pre-evaluation of function literals works if function declarations are swapped [1].
Christian
[1] https://github.com/BaseXdb/basex/issues/1052
On Fri, Jan 2, 2015 at 10:19 AM, jean-marc Mercier jeanmarc.mercier@gmail.com wrote:
Hello (and happy new year 2015 !)
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 ?
Cheers
Here is a code description :
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))
ouput : 3.1 ms 0.02 ms 100047.53 ms 134666491 134666491 134666491