Project

Profile

Help

Runtime analysis of xpath query

Added by Anonymous almost 16 years ago

Legacy ID: #5711608 Legacy Poster: Ido S. Yehieli (ido_yehi)

Can Saxon give an estimation of the complexity (in terms of runtime) of an xpath query (for example like Oracle can do for SQL queries)? If not, what would be the best way for me to calculate it, considering the optimizations saxon is using? It does not have be exact, being able to (automatically) produce ballpark estimates would be sufficient. -Ido.


Replies (5)

Please register to reply

RE: Runtime analysis of xpath query - Added by Anonymous almost 16 years ago

Legacy ID: #5711842 Legacy Poster: Michael Kay (mhkay)

No, sorry. Unlike Oracle, Saxon has no access to volumetric information about the instance data at the time a query is compiled, so the optimizer is not cost-based. Database products like Oracle have cost-based optimizers driven by statistics collected in the database, and their cost estimates are based on the calculations used by the optimizer. Saxon has to take the data as it comes. The -explain output from the optimizer gives information about the access paths that will be used at run-time and in principle you could try to work from this. You could also go a step further and work from the PathMap produced by path analysis, which is used (currently in XQuery only) to support document projection. But this is very low-level information and getting anything useful from it would be a substantial project.

RE: Runtime analysis of xpath query - Added by Anonymous almost 16 years ago

Legacy ID: #5711994 Legacy Poster: Ido S. Yehieli (ido_yehi)

Thanks. I am not sure how do get that output from the optimizer. I assume that Saxon's java library function XPathEvaluator.compile(String expr) eventually calls the optimzer internally?

RE: Runtime analysis of xpath query - Added by Anonymous almost 16 years ago

Legacy ID: #5712125 Legacy Poster: Michael Kay (mhkay)

However you compile an XPath or XQuery expression, you should be able to find your way to the net.sf.saxon.expr.Expression object that results from the compilation (you may have to dig down through a few wrappers depending on the API you use). This class has an explain() method. Actually it has two: one takes an OutputStream, which is useful if you just want to print the expression tree; the other takes an ExpressionPresenter, which is more useful if you want to process the tree. But before you attempt this, try it from the net.sf.saxon.Query command line with the -explain option, to see if the output is useful to you.

RE: Runtime analysis of xpath query - Added by Anonymous almost 16 years ago

Legacy ID: #5717592 Legacy Poster: Ignacio Hernandez-Ros (ignacioh)

This is indeed a very interesting question, and, maybe, something that can be further explored by Michael ... One way to optimize XQuery execution would be by having two methods for accessing information in one XML axis. The simplest method will be secuential method (current method). The alternative would be using an index on the information in the XML axis. The problem with the alternative method is that in order to "optimize" the query execution and decide going for method 2 (index) or method 1 (sequential access) some input is required during the xml parsing and the XQuery compilation in order to collect the information that goes in the index. Maybe an addition call to Processor with the following prototype: createIndex(String xpath2 expression) could help in order to tell the compiler and the document builder about what information should go in the index in order to accelerate XQuery.

RE: Runtime analysis of xpath query - Added by Anonymous almost 16 years ago

Legacy ID: #5717635 Legacy Poster: Michael Kay (mhkay)

Given a filter expression that is suitable for indexing, Saxon-SA will automatically index it. This is done without any knowledge of how many nodes will be present in the node sequence to be filtered - so it will sometimes be wasted effort, but it's well worth it for the savings that you get when handling large node sequences.

    (1-5/5)

    Please register to reply