XML QUERY LANGUAGES: XQUERY AND XPATH Even though the XML instance that is input to an XML function can be typed or untyped, remember that the result of an xml.query function is always an untyped XML instance. Typed XML should always be used, if possible, to give the XQuery engine a chance to use its knowledge of the data type involved. This also makes the resulting query run faster as well as producing more accurate results and fewer runtime errors. Optimization Decisions in the XQuery Engine The XQuery engine s implementation provides some optimizations over the the XQuery standard. It does this by restricting the functionality defined by the spec. There are four main restrictions: query over constructed sequences, usage of filter expressions other than at the end of the path, usage of order by with multiple or out-of-scope iterators and heterogeneous sequences. Here are some short examples. The following is a query over a constructed sequence. for $i in (for $j in //a return { $j }) return $i Next is a filter expression with a filter in the middle of the path. /a/b/(some-expression(.))/d Here is an example of using order bywith multiple iterators. for $x in //a for $y in //b order by $x > $y return $x, $y We ll discuss heterogeneous sequences in more detail here. In XQuery, sequences are defined to be able to contain all nodes, or all scalar values, or a combination of nodes and scalar values. SQL Server 2005 s XQuery engine restricts sequences to either all nodes or all scalar values; defining a heterogeneous sequence will result in an error. Permitting only homogeneous sequences allows the engine to optimize queries over sequences, because it will not try to determine the data type of each member of the sequence. Early SQL parsers were unoptimized; this was one of the reasons that early relational databases ran slowly. The performance improvement in relational databases since their inception is due, in no small way, to the optimization of SQL query processors, including static type analysis as

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

Bookmark the permalink.

Comments are closed.