Hey Again,
Sorry if I am here often. I got my system up and running and at first was seeing 1 second query times which is unacceptable. I started doing some research and trying different things. Here are some interesting things I found:
1) Using data() is SLOW!!! For example:
(//DataElement(data(Name) = 'Transformer'])[1] : this takes 350 ms avg to complete (Most of it evaluation)(//DataElement(Name = 'Transformer')[1] : this takes 4 - 10 ms.
Not sure why this is, but its good to know. I'm assuming the data() usage circumvents the indexes or something...
2) In a dynamic context is often worthwhile to 'construct' a query with the names embedded and execute xquery:eval rather than using variables within the expression. For example when trying to find a node based on a key property name which you don't know until run time:
($page:database//DataElement[(*|@*)[name() = $keyPropName)] = $entityId])[1]
Above query takes about 1200 ms to complete in our data. If you have more than one of these being executed, it jumps to 10,000 ms or more!!
xquery:eval("($context//" || $entityListName || "[" || $keyPropertyName || " = $entityId])[1]", map{ '$context' := $page:database, '$entityId' := $entityId })
This query takes between 2 - 8 ms to complete. Awesome!!
Just thought I would share my findings! So far I am really enjoying BaseX!! Thanks for all the hard work!
- James