Hi,
I want to share important feature of parentheses in XPath. When you are going to use Xquery in Applications, Its difficult to querying database without Predicates. When we use predicate means we have to use parentheses for increasing performance. For Example, Following query takes 45 seconds to execute
fn:doc("Test.xml")/root/result[child1="text1"][child2="text2"][child3="text3"]
But Following query takes only 7 seconds get the same result,
((( fn:doc("Test.xml")/root/result[child1="text1"] )[child2="text2"] )[child3="text3"])
How parentheses takes Minimum Time ?
The reason behind this is when we are using first XPath means it takes each record of selected document and apply all the predicates. But Second XPath Get the filtered records for first predicate and then only it applies the second predicate and then third predicate.
I want to share important feature of parentheses in XPath. When you are going to use Xquery in Applications, Its difficult to querying database without Predicates. When we use predicate means we have to use parentheses for increasing performance. For Example, Following query takes 45 seconds to execute
fn:doc("Test.xml")/root/result[child1="text1"][child2="text2"][child3="text3"]
But Following query takes only 7 seconds get the same result,
((( fn:doc("Test.xml")/root/result[child1="text1"] )[child2="text2"] )[child3="text3"])
How parentheses takes Minimum Time ?
The reason behind this is when we are using first XPath means it takes each record of selected document and apply all the predicates. But Second XPath Get the filtered records for first predicate and then only it applies the second predicate and then third predicate.
No comments:
Post a Comment