You don't say what $one_jurisdiction_code is bound to. Is it a huge sequence? Have you compared with using a literal value there? Probably not this, but every rock deserves a look I guess
-Mike On 5/7/2011 11:12 AM, Jakob Fix wrote: > hi, I'm trying to optimize a query that runs several seconds instead > of subseconds. > the number of documents in the database is very small (~4000), and the > documents themselves are in the sub-1K range. > > running the profiler on the code below shows that an inordinate amount > of time is spent in this line > let $these_agreements := > $the_agreements/*[/eoi:jurisdictions/eoi:jurisdiction eq > $one_jurisdiction_code] > > (btw, replacing the * with eoi:agreement which is the only root > element doesn't change a thing.) > > profiler output (first three lines, sorted by shallow us): > > .main: 18 > $the_agreements/eoi:agreement[/eoi:jurisdictions/eoi:jurisdiction > eq $one_jurisdiction_code] 107 71 1802951 98 2482631 > .main: 18 /eoi:jurisdictions/eoi:jurisdiction 335552 23 588809 > 23 588809 > .main: 18 /eoi:jurisdictions/eoi:jurisdiction eq > $one_jurisdiction_code 335552 3.6 90871 27 679680 > > i've created an element range index for the eoi:jurisdiction element > in order to speed things up, but the result is the same. so > apparently that's not the right thing. > i would be grateful for a hint as to how make this query quicker. > thanks, Jakob. > > > xquery version "1.0-ml"; > > declare namespace eoi = "http://www.oecd.org/eoi"; > import module namespace functx = "http://www.functx.com" at > "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy"; > > let $the_agreements := collection('http://www.eoi-portal.org/agreements') > let $code := "DE" > let $related_jurisdictions := functx:value-except( > fn:collection('http://www.eoi-portal.org/agreements') > /*[eoi:jurisdictions/eoi:jurisdiction eq > $code]/eoi:jurisdictions/eoi:jurisdiction, > ($code) > ) > > for $one_jurisdiction_code in $related_jurisdictions > (: all agreements between the two jurisdictions :) > let $these_agreements := > $the_agreements/*[/eoi:jurisdictions/eoi:jurisdiction eq > $one_jurisdiction_code] > > let $is_inforce := boolean($these_agreements/eoi:enforced/text()) > let $is_ratified := boolean($these_agreements/eoi:ratified/text()) > let $is_signed := boolean($these_agreements/eoi:signed/text()) > > return ( > $one_jurisdiction_code, > $is_inforce, > $is_ratified, > $is_signed > ) > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
