Hi Andrew, I agree, every processor has its own optimizations. :)
However, in the case of ML, I would stick with your original advice: use full paths to elements rather than //. In ML this allows the processor to use several indexes to resolve the full path, rather than a single index. I would also try to get your constraints into a single XPath expression rather than in the where clause of a FLWOR. Someone else from Mark Logic will chime in if these recommendations have changed, but I think they are safe. Kelly Message: 4 Date: Tue, 24 Nov 2009 09:53:59 +0000 From: Andrew Welch <andrew.j.we...@gmail.com> Subject: Re: [MarkLogic Dev General] XML structure/schema design for MLS To: General Mark Logic Developer Discussion <general@developer.marklogic.com> Message-ID: <74a894af0911240153i3f48f80n2e4e7a831ef86...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 2009/11/23 Lee, David <d...@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. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/ _______________________________________________ General mailing list General@developer.marklogic.com http://xqzone.com/mailman/listinfo/general