XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Ethan SteinSubject: xQuery Efficient Performance Best Practices
Author: Ethan Stein
Date: 01 Jul 2009 05:05 PM
Originally Posted: 01 Jul 2009 05:04 PM
I am trying to make an efficient xQuery and I am trying to decide on the best practices under the following conditions:

1. When using a comparison of two node values, where the node text values are both set to the value of 1, using = vs eq
2. When using a FLOWR statement, and including a where clause vs. an xpath comparison, e.g.

for $invoice in /Invoices/Invoice[./INVOICE_ID/text()=123]

vs.

for $invoice in /Invoices/Invoice
where $invoice/INVOICE_ID/text()=123


3. With declare option ddtek:xml-streaming set to yes, having an external variable

declare variable $xPRSXMLInput as document-node(element()) external;

set to

doc('converter:file:///c:/Documents%20and%20Settings/steine3/My%20Documents/Projects/Xerox%20Brazil/Aplicacao_DEMO/xerox_brazil.conv?file:///c:/Documents%20and%20Settings/steine3/My%20Documents/Projects/Xerox%20Brazil/Aplicacao_DEMO/Input/V01062009D_14052009075253_000000000000266.dat')

vs

external variable set to doc('file:///c:/Documents%20and%20Settings/steine3/My%20Documents/Projects/Xerox%20Brazil/Aplicacao_DEMO/xPRSXMLInput_Xerox.xml') where the XML file contains the contents:

<Input>
<File>c:/Documents%20and%20Settings/steine3/My%20Documents/Projects/Xerox%20Brazil/Aplicacao_DEMO/Input/V01062009D_14052009075253_000000000000266.dat</File>
</Input>

And then have the lines:

let $inputFile := $xPRSXMLInput/Input/File/text()
let $convertedFile := doc(fn:concat('converter:file:///',$confFile,'?file:///',$inputFile))


If anyone can shed some light on these as well as any other best practices with regards to xquery efficiency, it would be greatly apprecaited.

Thanks.

Postnext
Ivan PedruzziSubject: xQuery Efficient Performance Best Practices
Author: Ivan Pedruzzi
Date: 07 Jul 2009 02:02 AM

Hi Ethan,

Operator eq may be slightly faster, see the following for the semantic implications
http://www.xquery.com/tutorials/guided-tour/xquery-operators.html

The DataDirect XQuery optimizer almost always re-write predicates into where clause.

In version 4 calls to doc() with a dynamic value are evaluated in streaming fashion, that's not the case with earlier versions.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Ethan SteinSubject: xQuery Efficient Performance Best Practices
Author: Ethan Stein
Date: 07 Jul 2009 12:26 PM
So you're saying that XPath expressions are converted into where clauses automatically? So does that mean having it already be a where clause will help with performance, or is the difference negligable?

Also, can you further explain or give an example of how doc() expressions are treated in a streaming fashion?

Thanks.

Postnext
Ivan PedruzziSubject: xQuery Efficient Performance Best Practices
Author: Ivan Pedruzzi
Date: 07 Jul 2009 02:21 PM

The query optimization takes place at prepare time and yes is negligible.

In version 3 streaming mode worked only if the doc argument was a literal string

doc('converter:file:///c:/conv.conv?file:///c:/txt.txt'))

Starting with version 4, even if the argument is resolved at run-time

doc(fn:concat('converter:file:///',$confFile,'?file:///',$inputFile))

The query engine processes the input data in streaming fashion, without loading the entire document in memory.


Hope this helps
Ivan

Posttop
Ethan SteinSubject: xQuery Efficient Performance Best Practices
Author: Ethan Stein
Date: 07 Jul 2009 04:48 PM
So in that case, with xquery 3, having the doc as part of the whole external xquery variable will initiate streaming, but generating the doc() variable through contatenation inline in the xquery will not lead to streaming?

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.