Dear Charles,
First, a note that bears saying -- I'm very, *very* excited by BaseX; this is my first use of the database, and I'm already extremely impressed.
thanks for the positive feedback, always appreciated!
My immediate use case centers around the following pair of functions: [...] My expectation was that, due to XQuery's functional nature, the database should be able to avoid needing to evaluate local:immediate_requirements more than once for a single input element, capping the worst-case execution time not far over the cost of evaluating that single-stage evaluation once over every possible project element in the document; however, true worst-case execution time is obviously far worse.
While it's often difficult to give general advise on how to optimize XQuery expressions without looking at the actual data, it may help in your case to cache often requested database nodes in a variable and pass them on to the functions - or even put them in a global variable to get sure they'll only be evaluated once. Just a quick guess, your feedback is welcome.
Christian