[x-query-talk] trying to optimize xpath expression

Enric Jaen enric at nmg.upc.es
Fri Aug 25 23:34:17 PDT 2006

(Sorry if you receive this mail duplicated)

Hi all,

I'd like to improve the performance of the following simple xpath expression, used inside this simple XQuery function:

declare function foo($input as node()) as item()+ {
 for $elem in $input//EEE/FFF
 return $elem

 I know that the input document has an structure like:


The names of  AAA, BBB, CCC, and DDD are unknown.

I have tried changing the expression $input//EEE/FFF to:


which I think it should perform better because the lack of the '//' path  (please correct me if I am wrong), however the time consumed is very similar.

Similarly is happening with an XQuery function that performs:

which I have changed it to:

but the improvement is not that better.

I am using saxonB8.7.3, and I am calling the XQuery function from Java. I am trying with 1000 <EEE> elements. The function is compiled into an XQueryExpression before to invoke the UserFunction.call method. The input document is a DocumentWrapper object.

I wonder if there is something I can do to improve the performance of the Xpath expression?

Thanks in advance for any help.

 * Enric Jaen Villoldo
 * PhD student
 * http://nmg.upc.es/enric

More information about the talk mailing list