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
___________________________
On Tue, Jan 25, 2011 at 10:15 AM, Philip Oliver
<phil3(a)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
>
>