Hi Christian,
thanks for the fix, the result is correct now.
But this query now takes about 18 seconds (!) to execute, instead of <1
second like before. Do you think, this could be accelerated?
See attached for the complete console output.
Best,
Sebastian
Am 12.07.2018 um 13:03 schrieb Christian Grün:
Hi Sebastian,
This has been fixed. The background: In one of the optimizations of
the "if" expression, identical branches are merged:
if(..expensive query..) then 1 else 1
→ Optimized Query: 1
The full-text options were ignored in the equality check.
A new snapshot is online.
Best,
Christian
On Wed, Jul 11, 2018 at 1:22 PM Sebastian Zimmer
<sebastian.zim...@uni-koeln.de> wrote:
Hi,
I have a query which is optimized in a curious way in BaseX 9.0.2 (yesterday's
snapshot).
This is the original query:
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $string := "string"
let $fuzzy := false()
return (
collection('ZK')/tei:TEI[
if (false())
then (.[descendant::text() contains text {$string} using fuzzy])
else (.[descendant::text() contains text {$string}])
],
collection('ZK')/tei:TEI[
if ($fuzzy)
then (.[descendant::text() contains text {$string} using fuzzy])
else (.[descendant::text() contains text {$string}])
]
)
And this is the optimized one (newlines inserted by me for better readability):
(
ft:search("ZK", "string" using language
'English')/ancestor::tei:TEI[parent::document-node()],
ft:search("ZK", "string" using fuzzy using language
'English')/ancestor::tei:TEI[parent::document-node()]
)
I'm curious why the second search is using fuzzy, even though the variable
$fuzzy is false. I presume that query optimization is independent of the data,
so you won't need the data to reproduce. But if you do, I can provide it. A
database with enabled full-text index is required obviously.
Best regards,
Sebastian Zimmer
--
Sebastian Zimmer
sebastian.zim...@uni-koeln.de
Cologne Center for eHumanities
DH Center at the University of Cologne
@CCeHum
--
Sebastian Zimmer
sebastian.zim...@uni-koeln.de <mailto:sebastian.zim...@uni-koeln.de>
CCeH Logo <http://cceh.uni-koeln.de>
Cologne Center for eHumanities <http://cceh.uni-koeln.de>
DH Center at the University of Cologne
Twitter Logo <https://twitter.com/CCeHum>@CCeHum
<https://twitter.com/CCeHum>
szimmer1@luhmann1:/var/local/basex/webapp$ ../bin/basex -V
"./predicate_test.xql"
Query:
xquery version "3.1"; declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $string := "string" let $fuzzy := false() return (
collection('ZK')/tei:TEI[ if (false()) then (.[descendant::text() contains text
{$string} using fuzzy]) else (.[descendant::text() contains text {$string}]) ],
collection('ZK')/tei:TEI[ if ($fuzzy) then (.[descendant::text() contains text
{$string} using fuzzy]) else (.[descendant::text() contains text {$string}]) ] )
Compiling:
- pre-evaluate fn:collection([uri]) to document-node() sequence:
collection("ZK") -> (db:open-pre("ZK", 0), ...)
- rewrite if to iter filter: if(false()) then (.)[descendant::text() ... ->
(.)[descendant::text() contains text { $...
- rewrite iter filter to ftcontains: (.)[descendant::text() contains text {
$... -> descendant::text() contains text { $stri...
- rewrite iter filter to ftcontains: (.)[descendant::text() contains text {
$... -> descendant::text() contains text { $stri...
- apply full-text index for { $string_0 } using language 'English'
- pre-evaluate fn:collection([uri]) to document-node() sequence:
collection("ZK") -> (db:open-pre("ZK", 0), ...)
- inline $string_0
- inline $fuzzy_1
- rewrite if to iter filter: if(false()) then (.)[descendant::text() ... ->
(.)[descendant::text() contains text "st...
- rewrite iter filter to ftcontains: (.)[descendant::text() contains text
"st... -> descendant::text() contains text "string...
- rewrite iter filter to ftcontains: (.)[descendant::text() contains text
"st... -> descendant::text() contains text "string...
- simplify gflwor
Optimized Query:
(ft:search("ZK", "string" using language
'English')/ancestor::tei:TEI[parent::document-node()], (db:open-pre("ZK", 0),
...)/tei:TEI[descendant::text() contains text "string" using language
'English'])
Parsing: 321.15 ms
Compiling: 114.32 ms
Evaluating: 6.49 ms
Printing: 17467.63 ms
Total Time: 17909.59 ms
Hit(s): 0 Items
Updated: 0 Items
Printed: 0 b
Read Locking: ZK
Write Locking: (none)
Query "predicate_test.xql" executed in 17909.59 ms.
szimmer1@luhmann1:/var/local/basex/webapp$