Changes

Jump to navigation Jump to search
1,073 bytes added ,  17:45, 13 July 2020
no edit summary
# At parse time, the query string – an XQuery main module – is transformed to a tree representation, the ''abstract syntax tree'' (AST).
# At compile time, the syntax tree is decorated with additional information (type information, expression properties); expressions are relocated, simplified, or pre-evaluated:## Logical optimizations are ''context-independent''. They can be applied no matter which data will be processed later on.## Physical optimizations rely on context information, such as database statistics or available indexes.
# At evaluation time, the resulting expression tree is processed.
# The results are returned to the user. Some expression (such as simple loops) can be evaluated in iterative manner, whereas others (such as sort operations) need to be fully evaluated before the first result is available.
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.
=Compile-Time Logical Optimizations=
==Pre-Evaluation==
</syntaxhighlight>
=Physical Optimizations= ==Database Statistics== In each database, metadata is stored that can be utilized by the query optimizer to speed up or even skip query evaluation: ;Count element nodes The number of elements that are found for a specific path need not be evaluated sequentially. Instead, the count can directly be retrieved from the database statistics: <syntaxhighlight lang="xquery">count(/mondial/country) (: rewritten to :)231</syntaxhighlight> The distinct values for specific names and paths can also be fetched from the database metadata, provided that the number does not exceed the maximum number of distinct values (see {{Option|MAXCATS}} for more information): <syntaxhighlight lang="xquery">distinct-values(//religions) (: rewritten to :)('Muslim', 'Roman Catholic', 'Albanian Orthodox', ...)</syntaxhighlight> ==Index Rewritings==
A major feature of BaseX is the ability to rewrite all kinds of query patterns for [[Indexes|index access]].
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu