Re: [bdbxml] Varying XQuery performance with change in 'return' clause
"Deepak Jois" <[email protected]> Fri, 24 Feb 2006 15:07:36 +0800
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
> There are a couple of ways to tackle this - one is to try a query like th=
is:
>
> for $x in collection("genbank_bct.dbxml")/INSDSet/INSDSeq
> let $y :=3D INSDSeq_feature-table/INSDFeature/INSDFeature_quals/
> INSDQualifier/INSDQualifier_value
> where $y =3D "3.2.1.1"
> return $x/INSDSeq_locus
>
So, I executed two queries. One was
for $x in collection("genbank_bct.dbxml")/INSDSet/INSDSeq
let $y :=3D $x/INSDSeq_feature-table/INSDFeature/INSDFeature_quals/INSDQual=
ifier/INSDQualifier_value
where $y=3D"3.2.1.1"
return
$x/INSDSeq_locus
which was exactly the same as yours. This query took a long time to
execute. I stopped counting after about 10 mins. Its query plan was as
follows :
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
<XQuery>
<FLWOR>
<ForBinding name=3D"x">
<Navigation>
<QueryPlanFunction result=3D"collection" container=3D"genbank_bct.d=
bxml">
<OQPlan>U</OQPlan>
</QueryPlanFunction>
<Step axis=3D"child" name=3D"INSDSet" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDSeq" nodeType=3D"element"/>
</Navigation>
</ForBinding>
<LetBinding name=3D"y">
<Navigation>
<Variable name=3D"x"/>
<Step axis=3D"child" name=3D"INSDSeq_feature-table" nodeType=3D"ele=
ment"/>
<Step axis=3D"child" name=3D"INSDFeature" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDFeature_quals" nodeType=3D"element=
"/>
<Step axis=3D"child" name=3D"INSDQualifier" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDQualifier_value" nodeType=3D"eleme=
nt">
<OQPlan>P(edge-element-equality-string,prefix,INSDQualifier.INSDQ=
ualifier_value)</OQPlan>
</Step>
</Navigation>
<Where>
<Navigation>
<Variable name=3D"y"/>
<DbXmlCompare name=3D"equal">
<OQPlan>V(edge-element-equality-string,INSDQualifier.INSDQualif=
ier_value,=3D,'3.2.1.1')</OQPlan>
<Sequence>
<AnyAtomicTypeConstructor value=3D"3.2.1.1"
typeuri=3D"http://www.w3.org/2001/XMLSchema" typename=3D"string"/>
</Sequence>
</DbXmlCompare>
</Navigation>
</Where>
</LetBinding>
<Navigation>
<Variable name=3D"x"/>
<Step axis=3D"child" name=3D"INSDSeq_locus" nodeType=3D"element">
<OQPlan>P(unique-edge-element-equality-string,prefix,INSDSeq.INSDSe=
q_locus)</OQPlan>
</Step>
</Navigation>
</FLWOR>
</XQuery>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
Then, I executed the following query :
for $x in collection("genbank_bct.dbxml")/INSDSet/INSDSeq/INSDSeq_feature-t=
able/INSDFeature/INSDFeature_quals/INSDQualifier[INSDQualifier_value=3D"3.2=
.1.1"]
return
$x/../../../../INSDSeq_locus
This query came back in about 4 mins as I reported earlier. The query
plan was as follows :
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
<XQuery>
<Navigation>
<QueryPlanFunction result=3D"collection" container=3D"genbank_bct.dbxml=
">
<OQPlan>n(P(unique-edge-element-equality-string,prefix,INSDSeq.INSDSe=
q_locus),V(edge-element-equality-string,INSDQualifier.INSDQualifier_value,=
=3D,'3.2.1.1'))</OQPlan>
</QueryPlanFunction>
<Step axis=3D"child" name=3D"INSDSet" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDSeq" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDSeq_feature-table" nodeType=3D"element=
"/>
<Step axis=3D"child" name=3D"INSDFeature" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDFeature_quals" nodeType=3D"element"/>
<Step axis=3D"child" name=3D"INSDQualifier" nodeType=3D"element"/>
<DbXmlFilter>
<Navigation>
<Step axis=3D"child" name=3D"INSDQualifier_value" nodeType=3D"eleme=
nt"/>
<DbXmlCompare name=3D"equal">
<Sequence>
<AnyAtomicTypeConstructor value=3D"3.2.1.1"
typeuri=3D"http://www.w3.org/2001/XMLSchema" typename=3D"string"/>
</Sequence>
</DbXmlCompare>
</Navigation>
</DbXmlFilter>
<Step axis=3D"parent" uri=3D"*" name=3D"*" nodeType=3D"*"/>
<Step axis=3D"parent" uri=3D"*" name=3D"*" nodeType=3D"*"/>
<Step axis=3D"parent" uri=3D"*" name=3D"*" nodeType=3D"*"/>
<Step axis=3D"parent" uri=3D"*" name=3D"*" nodeType=3D"*"/>
<Step axis=3D"child" name=3D"INSDSeq_locus" nodeType=3D"element"/>
</Navigation>
</XQuery>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
So, I guess it doesnt help as far as reducing the query times is
concerned. I would like to know what exactly is happening in the first
case.
Can I try something else to bring the query times below 4 mins that is
the current best.
Thanks
Deepak
------------------------------------------
To remove yourself from this list, send an
email to [email protected]