I profiled the db:open() and collection() calls and they were basically instantaneous. Moving to using db:attribute() and the index makes my process 100x times faster. Now I feel like a bit of an idiot for not having figured this out sooner. Somebody needs to write the Optimizing BaseX book…. Cheers, E. _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: BaseX-Talk <basex-talk-bounces@mailman.uni-konstanz.de> on behalf of Liam R. E. Quin <liam@fromoldbooks.org> Date: Friday, July 15, 2022 at 4:55 PM To: basex-talk@mailman.uni-konstanz.de <basex-talk@mailman.uni-konstanz.de> Subject: Re: [basex-talk] Possible to Speed Up This Lookup? [External Email] On Fri, 2022-07-15 at 21:20 +0000, Eliot Kimber wrote:
return (db:option('attrindex'), for $node in $map return prof:track(db:open($rkDatabase)/doc-where-used- index/where-used-entry/@key[xs:integer(.) eq 9151416])?time ! util:formatTime(.)
can you take the db:open() call out and see how much faster the expression runs without it? return (db:option('attrindex'), let $db := db:open($rkDatabase) return for $node in $map return prof:track($db/doc-where-used-index/where-used-entry /@key[xs:integer(.) eq 9151416])?time ! util:formatTime(.) (if i have that right) -- Liam Quin, https://urldefense.com/v3/__https://www.delightfulcomputing.com/__;!!N4vogdjhuJM!Ge6_HxIH-uWYEol5ImGje0BVsQ_FKkbp1x9czcNl7d0t6BKvoQ1v0sENn6_kHvOQI0dfFmEig6LEfg3dDcIyNVA$<https://urldefense.com/v3/__https:/www.delightfulcomputing.com/__;!!N4vogdjhuJM!Ge6_HxIH-uWYEol5ImGje0BVsQ_FKkbp1x9czcNl7d0t6BKvoQ1v0sENn6_kHvOQI0dfFmEig6LEfg3dDcIyNVA$> Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: https://urldefense.com/v3/__http://www.fromoldbooks.org__;!!N4vogdjhuJM!Ge6_HxIH-uWYEol5ImGje0BVsQ_FKkbp1x9czcNl7d0t6BKvoQ1v0sENn6_kHvOQI0dfFmEig6LEfg3dk_syZfc$<https://urldefense.com/v3/__http:/www.fromoldbooks.org__;!!N4vogdjhuJM!Ge6_HxIH-uWYEol5ImGje0BVsQ_FKkbp1x9czcNl7d0t6BKvoQ1v0sENn6_kHvOQI0dfFmEig6LEfg3dk_syZfc$>