BaseX 9.5.2 simple query has slow Compilation time
Tuesday, 13 July 2021 · 2 messages
A
arcogabbo13 Jul 2021 13:09 #
Hi,
I admit this is my first experience with BaseX and XQuery language, but this seems weird and i can't find anything on docs or issues related to this.
I created a random dataset of calls and i wanted to query this dataset using XQuery,
however it turns out compile time takes too long for a relatively simple query.
The dataset can be found here
<https://gist.github.com/arcogabbo/8042d08b1feb5c860f86ff46d4333e84> .
The query is:
doc("basex/etc/dataset25k.xml")/users/user[number= "605 6230540" and calls/call/location/@city = "Sandy Springs"]/fullName
Timing:
- Parsing: 0.61 ms
- Compiling: 382.43 ms
- Evaluating: 2.1 ms
- Printing: 0.14 ms
- Total Time: 385.28 ms
Compiling:
- rewrite
fn:doc(uri) to document-node() item:
doc("basex/etc/dataset25k.xml") -> document {
"file:///home/arcogabbo/Scrivania/basex/etc/dataset25k.xml" }
- rewrite to predicate: ((number = "605 6230540") and
(calls/call/location/@city = "Sandy Springs"))
- apply attribute index for "Sandy Springs"
Even if i try a simple query on the example dataset of the
application(factbook.xml) the compilation time takes too long, for example:
Query:
doc("basex/etc/factbook.xml")/mondial/country[@name="Norway"]/province/city
Timing:
- Parsing: 0.34 ms
- Compiling: 82.29 ms
- Evaluating: 1.05 ms
- Printing: 1.49 ms
- Total Time: 85.17 ms
Compiling:
- rewrite fn:doc(uri) to document-node() item:
doc("basex/etc/factbook.xml") -> document {
"file:///home/arcogabbo/Scrivania/basex/etc/factbook.xml" }
- apply attribute index for "Norway"
I also tried BaseX version 9.5 and on another computer, yet compilation times are approximately the same. Any help is appreciated.CG
Christian Grün13 Jul 2021 13:18 #
Hi arcogabbo,
Nearly 100% of the compile time is caused by the parsing of your 8 MB input file. If you create a database from the XML file, your query will be evaluated much faster.
After you have created the database, you can save additional time by using db:open('name-of-the-db') instead of
doc('name-of-the-input.xml').
Hope this helps,
Christian
Quoted text · arcogabbo · 41 lines
On Tue, Jul 13, 2021 at 1:09 PM arcogabbo <arcogabbo at gmail.com> wrote: > > Hi, > I admit this is my first experience with BaseX and XQuery language, but this seems weird and i can't find anything on docs or issues related to this. > I created a random dataset of calls and i wanted to query this dataset using XQuery, > however it turns out compile time takes too long for a relatively simple query. > The dataset can be found here . > > The query is: > doc("basex/etc/dataset25k.xml")/users/user[number= "605 6230540" and calls/call/location/@city = "Sandy Springs"]/fullName > > Timing: > - Parsing: 0.61 ms > - Compiling: 382.43 ms > - Evaluating: 2.1 ms > - Printing: 0.14 ms > - Total Time: 385.28 ms > > Compiling: > - rewrite fn:doc(uri) to document-node() item: doc("basex/etc/dataset25k.xml") -> document { "file:///home/arcogabbo/Scrivania/basex/etc/dataset25k.xml" } > - rewrite to predicate: ((number = "605 6230540") and (calls/call/location/@city = "Sandy Springs")) > - apply attribute index for "Sandy Springs" > > Even if i try a simple query on the example dataset of the application(factbook.xml) the compilation time takes too long, for example: > > Query: > doc("basex/etc/factbook.xml")/mondial/country[@name="Norway"]/province/city > > Timing: > - Parsing: 0.34 ms > - Compiling: 82.29 ms > - Evaluating: 1.05 ms > - Printing: 1.49 ms > - Total Time: 85.17 ms > > Compiling: > - rewrite fn:doc(uri) to document-node() item: doc("basex/etc/factbook.xml") -> document { "file:///home/arcogabbo/Scrivania/basex/etc/factbook.xml" } > - apply attribute index for "Norway" > > I also tried BaseX version 9.5 and on another computer, yet compilation times are approximately the same. Any help is appreciated. >
Written for BaseX 9.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery