An apparatus,
system, and method are disclosed for optimization of
XPath expressions in a
database management system configured to accept
XML queries. Operations of the method include receiving an
XQuery representation and partitioning
XPath expressions within the
XQuery representation into a plurality of
XPath expression clusters. The
XPath expression clusters may comprise one or more XPath expressions and those in each cluster may operate on a common document. Furthermore, the XPath expressions in each cluster are hierarchically related to each other such that
branch nodes of the cluster are
executable independent of nodes in other
XPath expression clusters. The method also defines merging the one or more XPath expressions into one or more expression trees for each
XPath expression cluster. The method generates one or more query execution plans from the one or more XPath expression blocks. The method includes, for each query
execution plan, splitting each of the XPath expression blocks into one or more ordered fragments. The method determines a cardinality according to
database statistics and an execution cost for each XPath expression block within each query
execution plan. Finally, the method determines an aggregate cardinality for each query
execution plan and an aggregate execution cost for each query execution plan. Therefore, an
XQuery may be optimized at both the global XQuery and local XPath expression
block level, improving performance and reducing overhead.