Hi Eliot -
Others are much more proficient and knowledgeable, but I try the following:
1. ABI := Always Be Indexing :) 2. I think that Christian has expressed that, with indexes in play, many queries can experience significant optimizations by reversing the query pattern; eg starting with the attribute value and working back up from there, etc. 3. The optimized query view can be super helpful in this regard, too.
I'm sure there are other, better habits and strategies, I know (I just don't have them ingrained! 🙂). Other users will share, I'm sure.
Have a pleasant weekend! Best, Bridger
On Fri, Jul 15, 2022, 6:01 PM Eliot Kimber eliot.kimber@servicenow.com wrote:
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/__;!!N4vogdj... 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_... https://urldefense.com/v3/__http:/www.fromoldbooks.org__;!!N4vogdjhuJM!Ge6_HxIH-uWYEol5ImGje0BVsQ_FKkbp1x9czcNl7d0t6BKvoQ1v0sENn6_kHvOQI0dfFmEig6LEfg3dk_syZfc$