Re: [bdbxml] Varying XQuery performance with change in 'return' clause
John Snelson <[email protected]> Fri, 24 Feb 2006 09:49:43 +0000
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
Deepak Jois wrote:
> =====
> for $x in collection("genbank_bct.dbxml")/INSDSet/INSDSeq[INSDSeq_locus="AE017283"]
> return
> $x
> =====
> Returns instantly.
This could just as well be written:
collection("genbank_bct.dbxml")/INSDSet/INSDSeq[INSDSeq_locus="AE017283"]
> whereas,
> =====
> for $x in collection("genbank_bct.dbxml")/INSDSet/INSDSeq
> let $y := $x/INSDSeq_locus
> where $y = "AE017283"
> return
> $x
> =====
>
> Takes extremely long!
It is the let clause, that seems to force the query to execute as a loop
instead of a pipeline. I'll have to look into how we can optimise these
situations.
In cases where the comparison operator does not form a "join" (it has
nodes on both sides of it), the size of the node producing expression
does not matter. You can just as well write:
for $x in collection("genbank_bct.dbxml")/INSDSet/INSDSeq
where $x/INSDSeq_locus = "AE017283"
return
$x
In fact, if you look at the query plan for this query and compare it to
your first query, they will be almost identical.
John
--
John Snelson, Berkeley DB XML Engineer
Sleepycat Software, Inc
http://www.sleepycat.com
Contracted to Sleepycat through Parthenon Computing Ltd
http://blog.parthcomp.com/dbxml
------------------------------------------
To remove yourself from this list, send an
email to [email protected]