Strange query plan difference

Tuesday, 25 January 2011 · 2 messages
CG
Christian Grün25 Jan 2011 11:56 #
Hi Philip (cc:mailing list), does the index still work if you reopen the GUI and run your query? Next, which full-text options have you set? Christian
Quoted text · Philip Oliver · 124 lines
On Tue, Jan 25, 2011 at 10:15 AM, Philip Oliver <phil3 at olivercomputing.com> wrote: > Christian - I've gotten around to trying BaseX 6.5.1 (generated from SVN) with some code changes, and I'm trying to figure out some strange behavior: a query executed in the GUI is using an index, whereas the same query executed in my program via client/server execution, does not (so is very slow.) > > (One thing I've noticed is that the fulltext indices are not used if the "English" language option is chosen. I figure this is the same principle as the indices not being used if the "contains text" query options don't match the database fulltext index properties - but I don't know what fulltext options to use in the query, then. I don't know if this is related to the problem I'm seeing.) > > ---------------------------------------- > This is the query: > > let $paras:=db:open('CIVWAR')//node()[text() contains text "ohio"] let $books:=$paras/ancestor::book return (for $book in $books where exists($book/@id) order by number($book/@id) return <book id="{$book/@id}" series="{$book/@series}" title="{$book/title}"/>) > > ---------------------------------------- > This is the result of session.info() with "set queryinfo on", after the query is executed in my program: > > Query: let $paras:=db:open('CIVWAR')//node()[text() contains text "zanesville"] let $books:=$paras/ancestor::book return (for $book in $books where exists($book/@id) order by number($book/@id) return <book id="{$book/@id}" series="{$book/@series}" title="{$book/title}"/>) > > Compiling: > - pre-evaluating open("CIVWAR") > - optimizing descendant-or-self step(s) > - binding static variable $paras > - merging axis paths > - binding static variable $books > - rewriting where clause to predicate(s) > - rewriting exists(@*:id) > - removing variable $paras > - removing variable $books > - simplifying flwor expression > > Result: for $book in (document-node { "DYERS_P1.xml" }, ...)/descendant::node()[text() contains text "zanesville"]/ancestor::*:book[@*:id] order by number($book/@id) return element { "book" } { attribute { "id" } { $book/@id }, attribute { "series" } { $book/@series }, attribute { "title" } { $book/title } } > > Parsing: 1.83 ms > Compiling: 8.73 ms > Evaluating: 36902.45 ms > Printing: 0.71 ms > Total Time: 36913.74 ms > Results: 15 Items > Updated: 0 Items > Printed: 964 Bytes > Memory: 11970 KB > > Query executed in 36914.08 ms. > > > ---------------------------------------- > And this is the query info from the GUI: > > Query: let $paras:=db:open('CIVWAR')//node()[text() contains text "ohio"] let $books:=$paras/ancestor::book return (for $book in $books where exists($book/@id) order by number($book/@id) return <book id="{$book/@id}" series="{$book/@series}" title="{$book/title}"/>) > Compiling: > - pre-evaluating open("CIVWAR") > - optimizing descendant-or-self step(s) > - applying full-text index > - binding static variable $paras > - merging axis paths > - binding static variable $books > - rewriting where clause to predicate(s) > - rewriting exists(@id) > - removing variable $paras > - removing variable $books > - simplifying flwor expression > Result: for $book in FTIndexAccess("CIVWAR", "ohio")/..[ancestor::document-node()]/ancestor::book[@id] order by number($book/@id) return element { "book" } { attribute { "id" } { $book/@id }, attribute { "series" } { $book/@series }, attribute { "title" } { $book/title } } > Query plan: > <GFLWOR> > <For var="$book"> > <AxisPath> > <FTIndexAccess data="CIVWAR"> > <FTWords>ohio</FTWords> > </FTIndexAccess> > <IterStep axis="parent" test="node()"> > <AxisPath> > <IterStep axis="ancestor" test="document-node()"/> > </AxisPath> > </IterStep> > <IterStep axis="ancestor" test="book"> > <AxisPath> > <IterStep axis="attribute" test="id"/> > </AxisPath> > </IterStep> > </AxisPath> > </For> > <Order> > <OrderByExpr dir="ascending" empty="least"> > <FNAcc name="number(item?)"> > <AxisPath> > <VarRef name="$book"/> > <IterStep axis="attribute" test="id"/> > </AxisPath> > </FNAcc> > </OrderByExpr> > </Order> > <Return> > <CElem> > <Item value="book" type="xs:QName"/> > <CAttr> > <Item value="id" type="xs:QName"/> > <AxisPath> > <VarRef name="$book"/> > <IterStep axis="attribute" test="id"/> > </AxisPath> > </CAttr> > <CAttr> > <Item value="series" type="xs:QName"/> > <AxisPath> > <VarRef name="$book"/> > <IterStep axis="attribute" test="series"/> > </AxisPath> > </CAttr> > <CAttr> > <Item value="title" type="xs:QName"/> > <AxisPath> > <VarRef name="$book"/> > <IterStep axis="child" test="title"/> > </AxisPath> > </CAttr> > </CElem> > </Return> > </GFLWOR> > Timing: > - Parsing: 0.99 ms > - Compiling: 0.59 ms > - Evaluating: 864.56 ms > - Printing: 1.09 ms > - Total Time: 867.25 ms > >
N
NewIntellectual25 Jan 2011 22:24 #
On Tue, Jan 25, 2011 at 5:56 AM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 3 lines
> does the index still work if you reopen the GUI and run your query? > Next, which full-text options have you set? >
After doing a few things such as closing Eclipse and restarting the BaseX server, the problem mysteriously disappeared. So I'm not sure what was happening.

⚡Generated with XQuery