Changes

Jump to navigation Jump to search
22 bytes removed ,  08:51, 19 July 2022
no edit summary
This article is part of the [[XQuery|XQuery Portal]]. Optimizations are presented It presents some of the optimizations that speed up the execution time and reduce memory consumption. The text will be regularly extended with further examplesof queries.
=Introduction=
An XQuery expression is evaluated in Query execution encompasses multiple steps:
# At parse time, the '''Parsing''': The query input string – an XQuery main module – is transformed to executable code. The result is a tree representation, called the ''abstract syntax tree'' (AST).# At compile time, the '''Compilation''': The syntax tree is decorated with additional information (type information, expression properties); expressions . Expressions (nodes) in the tree are relocated, simplified, or pre-evaluated:## . Logical optimizations are performed that do not rely on external information.# '''context-independentOptimization'''. They can be applied no matter which data will be processed later on.## Physical optimizations rely on : The dynamic context information, such as database statistics or is incorporated: Referenced databases are opened and analyzed; queries are rewritten to use available indexes; accumulative and statistical operations (counts, summations, min/max, distinct values) are pre-evaluated; XPath expressions are simplified, based on the existence of steps.# At evaluation time, the '''Evaluation''': The resulting expression tree code is processedexecuted.# '''Printing''': The results are returned to the user. Some expression (such as simple loops) can be evaluated query result is serialized and presented in iterative mannera format that is either human-readable, whereas others (such as sort operations) need to or can be fully evaluated before the first result is availablefurther processed by an API.
Each of the steps allows for numerous optimizations, some of which Some rewritings are described in this article.
If you run a query on [[Command-Line_Options#Standalone|command-line]], you can use {{Code|-V}} to output detailed query information. In the [[GUI]], you can enable the Info View panel.
=Logical OptimizationsCompilation=
==Pre-Evaluation==
* <code>true#0 and true#0</code> must raise an error; it cannot be simplified to <code>true#0</code>
=Physical OptimizationsOptimization=
Some physical optimizations are also presented in the article on [[Indexes|index structures]].
If the accessed database is not known at compile time, or if you want to give a predicate preference to another one, you can [[Indexes#Enforce Rewritings|enforce index rewritings]].
=Evaluation-Time Optimizations=
==Comparisons==
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu