[xquery-talk] How can I optimize time in query

Michael Kay mike at saxonica.com
Wed Apr 6 14:58:02 PDT 2011


You're very dependent on the query optimizer for this. It all depends 
which XQuery engine you are using. The commercial edition of Saxon, for 
example (Saxon-EE) will do a much better job on it than the home edition 
(Saxon-HE).

Michael Kay
Saxonica

On 06/04/2011 12:37, Kunal Chauhan wrote:
> Hi All,
> I wrote one XQuery it's work but taking time I want to optimize time 
> taken by that XQuery.
> Here I explaine a brief scenario.
> There are two diff xml files. I need to check first xml file's tag's 
> attributes value and check it into second file
> If this value is same than I need to go forward for more process.
> I used for loop for it but it takes time so how can I optimize time in 
> this case.
> here is example
> *First XML file*
> <?xml version="1.0" encoding="US-ASCII"?>
> <doc1>
> <info id="1">
> <fname>Kunal</fname>
> <lname>chauhan</lname>
> </info>
> <info id="2">
> <fname>Bhavik</fname>
> <lname>Solanki</lname>
> </info>
> <info id="3">
> <fname>Geet</fname>
> <lname>Gangwar</lname>
> </info>
> </doc1>
> *Second XML file*
> <?xml version="1.0" encoding="US-ASCII"?>
> <Doc2>
> <empinfo id="1">
> <name>Kunal</name>
> <dept>tech</dept>
> <roll>prog</roll>
> </empinfo>
> <empinfo id="2">
> <name>Bhavik</name>
> <dept>tech</dept>
> <roll>prog</roll>
> </empinfo>
> <empinfo id="3">
> <name>Geet</name>
> <dept>tech</dept>
> <roll>tl</roll>
> </empinfo>
> </Doc2>
> *XQuery*
> let $d1 := doc("D:/xbrl/NewDoc1.xml")
> let $d2 := doc("D:/xbrl/NewDoc2.xml")
>
> for $x in $d1,$y in $d2
> check ($x/doc1/info/@id = $y/Doc2/empinfo/attribute::id)   // check 
> ids of each node and if they are same than process forward
> ...
> ...
> ..
> return $y/Doc2/empinfo/name
> in this example I just return name but actualyy if ids are same than I 
> need to go forward and do some more process and after that return 
> final result.
> so is there any other way, other than for loop
> Thanks & Regards,
>
> *Kunal Chauhan*
> mail4ck at gmail.com <mailto:mail4ck at gmail.com>
> [+918655517141]
> [+919904983614]
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20110406/51d5b8c0/attachment.htm


More information about the talk mailing list