[MarkLogic Dev General] XML structure/schema design for MLS
andrew.j.welch at gmail.com
Tue Nov 24 01:53:59 PST 2009
2009/11/23 Lee, David <dlee at epocrates.com>:
> I think what Karl is expressing is frustration that basic xpath
> expressions appear not to use indexes.
> I too am 'in the dark' about that ... and would love some advise.
> Why, for example
> cts:search( doc("doc.xml")/FOO/BAR , "text")
> uses index ("instant results" )
> but apparently
> doc("doc.xml")/FOO[BAR eq 'text']
> seems to iterate through the list and not use indexes. (painfully slow
> results ... )
Quite often it's down to the processor being able to recognise what
you are trying to do and then rewrite it to be faster. In XSLT the
usual advice is specify the full path and avoid //foo because it
requires walking the entire input tree, but with a database it's
better to avoid the full path and use // instead (where the results
would be the same) because indexes can be used.
I've also heard that using a flowr expression instead of single xpath
can help because it simplifies the expression which helps the
processor spot what it can optimise.
More information about the General