Dear Ronny,
I would dare claim that BaseX provides one of the most advanced query compilers/optimizers for XQuery which you can find out there. Still, due to the complexity of the language, there are many cases in which queries can be further sped up by manually rewriting them. This is just what you did (and as we do for commercial customers).
In the particular case, we don't know at compile time which nodes will be bound to the $semxml variable. It could even be that the bound nodes will refer to different databases, in which case we'd have to provide different path rewritings for the same original path.
Hope this helps, Christian Am 30.03.2012 14:06 schrieb "Ronny Möbius" moebius@physik.hu-berlin.de:
Hi for another time,
I found a big performance killer by myself.
On 03/29/2012 12:18 PM, Ronny Möbius wrote:
declare function vlvz:getlvs($semxml as node()*,$modabbr as xs:string) as node()* { for $l in $semxml//Lesson where $l[AssociatedModules/Module/@Abbr=$modabbr] order by data($l/@ID) return $l };
Replacing "$semxml//Lesson" by "$semxml/Dataset/Lessons/Lesson" makes a difference of about one third of time spent.
Why is that? I thought, I don't have to care about the inefficiency of "//". Isn’t that handled by indices?
All the best, Ronny _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk