Subject: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;
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:
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?
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?