Thanks for the response. In the API, It looks like I can make use of precompiled queries; is this so? If so, and I precompile the query, will it still be optimized at runtime, or will it be executed exactly as it is written?
Dear Travis,
it always depends on the XQuery implementation, and its optimizer,
which query variant will be evaluated more efficiently. In BaseX, your
two example queries...
for $x in doc('test')/* where $x/node="value" return $x
for $x in doc('test')/*[node="value"] return $x...will both be simplified/rewritten to this query:
doc('test')/*[node="value"]
The "Query Info" panel in BaseX will give you more insight on how your
queries are compiled and optimized.
Hope this helps,
Christian
___________________________
On Sun, Jan 31, 2010 at 10:57 PM, Travis Webb <tjwebb@vt.edu> wrote:
> I'm trying to figure out which is more efficient (xpath or xquery select),
> so if someone has knowledge on this I'd appreciate any input. This may or
> may not be specific to the implementation of BaseX.
> For example, the following queries return the same thing, but which one is
> faster? Does basex treat them the same way? 1 uses xquery select, 2 uses
> xpath
> 1. for $x in doc('test')/* where $x/node="value" return $x
> OR
> 2. for $x in doc('test')/*[node="value"] return $x
> Thanks.
> -tjw
Christian Gruen
Universitaet Konstanz
Department of Computer & Information Science
D-78457 Konstanz, Germany
Tel: +49 (0)7531/88-4449, Fax: +49 (0)7531/88-3577
http://www.inf.uni-konstanz.de/~gruen