Optimized FLWOR in 9.0.0 takes quite long
See original GitHub issueI think a regression occured with BaseX 9.0.0.
Running the exact same query in 8.6.7 and 9.0.0 results in very different durations. In 8.6.7 it looks like this:
Parsing: 456.59 ms
Compiling: 98.72 ms
Evaluating: 8.04 ms
Printing: 33.78 ms
Total Time: 597.13 ms
Hit(s): 1 Item
Updated: 0 Items
Printed: 637 b
Read Locking: (global)
Write Locking: (none)
Query "get_zettel.xql" executed in 597.13 ms.
In 9.0.0 :
Parsing: 575.18 ms
Compiling: 83.79 ms
Evaluating: 9.17 ms
Printing: 9007.55 ms
Total Time: 9675.7 ms
Hit(s): 1 Item
Updated: 0 Items
Printed: 637 b
Read Locking: (global)
Write Locking: (none)
Query "get_zettel.xql" executed in 9675.7 ms.
Here are the optimized queries for both versions, they differ a bit. I have added some indentation for better readability:
9.0.0
Optimized Query:
let $zettel_368 := db:attribute("ZK", "ZK_1_NB_1-1a_V")/self::xml:id/parent::tei:div[parent::tei:body/parent::tei:text/parent::tei:TEI/parent::document-node()]
let $ekin_370 := data($zettel_368/@xml:id)
return array {
for $ptr_371 in $zettel_368/ancestor::tei:TEI/tei:text/tei:back/tei:div[(@type = "navigation")]/tei:p/tei:linkGrp[(@type = "logical_navigation")]/tei:ptr
let $value_372 := data($ptr_371/@target)
where (($value_372 != "#") and (substring($value_372, 2) != $ekin_370))
return map {
"relation": data($ptr_371/@type),
"ekin": substring($value_372, 2),
"image_id": data((db:open-pre("ZK", 0), ...)/tei:TEI/tei:text/tei:body/tei:div[(@xml:id = substring($value_372, 2))]/tei:pb/@facs),
"number": data((db:open-pre("ZK", 0), ...)/tei:TEI/tei:text/tei:body/tei:div[(@xml:id = substring($value_372, 2))]/ancestor::tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/tei:altIdentifier[(@type = "myproject")]/tei:idno[(@type = "title")]/@n)
}
}
8.6.7
Optimized Query:
let $zettel_368 := db:attribute("ZK", "ZK_1_NB_1-1a_V")/self::xml:id/parent::tei:div[parent::tei:body/parent::tei:text/parent::tei:TEI/parent::document-node()]
let $ekin_370 := data($zettel_368/@xml:id)
return [
for $ptr_371 in $zettel_368/ancestor::tei:TEI/tei:text/tei:back/tei:div[(@type = "navigation")]/tei:p/tei:linkGrp[(@type = "logical_navigation")]/tei:ptr
let $value_372 := data($ptr_371/@target)
where (($value_372 != "#") and (substring($value_372, 2) != $ekin_370))
return map {
"relation":data($ptr_371/@type),
"ekin":substring($value_372, 2),
"image_id":data(db:attribute("ZK", substring($value_372, 2))/self::xml:id/parent::tei:div[parent::tei:body/parent::tei:text/parent::tei:TEI/parent::document-node()]/tei:pb/@facs),
"number":data(db:attribute("ZK", substring($value_372, 2))/self::xml:id/parent::tei:div[parent::tei:body/parent::tei:text/parent::tei:TEI/parent::document-node()]/ancestor::tei:TEI/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msIdentifier/tei:altIdentifier[(@type = "myproject")]/tei:idno[(@type = "title")]/@n)
}
]
In both instances, the attribute index is enabled. You can see, that it is also used in 9.0.0, but not as much as in 8.6.7. Also, in 9.0.0, the database is 794 MB large, in 8.6.7 only 636 MB, if that matters. Both have been created with the same script of course. I’m happy to supply more information, if needed.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Mocha® 2022 User Guide - Boris FX
Generating keyframe data can take some time for very long shots. You can cancel generation at any time when the progress bar appears....
Read more >Lifetime Free Updates - FL Studio
Because we believe you should get the program you paid for, bug-fixed and updated for as long as we develop FL Studio. Lifetime...
Read more >TIBCO WebFOCUS® App Studio User's Manual Release 9.0.0
TIBCO WebFOCUS® is a complete, web-ready data access and reporting system that connects users to data. It accesses and processes information located in...
Read more >NEW* PIXELMON MOD MAJOR UPDATE - YouTube
This update takes Pixelmon from 1.12.2 and updates it to 1.16.5 after so long we finally have Pixelmon in at least the 2nd...
Read more >A Complete and Efficient Algebraic Compiler for XQuery
We describe the compilation rules for the complete language into that algebra and present novel optimization techniques that address the needs of complex....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks similar to https://www.mail-archive.com/basex-talk@mailman.uni-konstanz.de/msg10396.html, as I just noticed… Good to hear that your recreated database is smaller now!
Yes! I can confirm that the query printing times are perfectly low again with the latest snapshot. Thanks for the fix!