From: Raul D. <r.d...@dm...> - 2007-08-15 17:51:51
|
Hi Gary, Thank you for your reply :) The reason why I can't do what you suggest is because of the structure of my documents. I have in each document several result nodes under "results". So your XQuery will bring me all the pricing nodes, that will include all the result types, whereas I'm searching for a specific one. For me the driver is the result type (@name='mtm' and @type='value'), and I want only those result nodes. What I tried first was to iterate over the pricings, then for each pricing select specifically the result nodes I wanted, but it was incredibly slow. This solution is much much faster (3 seconds for each type of result across 4.000 documents, and 60 seconds for producing 45.000 result lines). Thanks all the same for your help :) regards, Raul >> >> >> -----Original Message----- >> From: Gary Larsen [mailto:gar...@en...] >> Sent: Wednesday, August 15, 2007 1:23 PM >> To: 'Raul Davidovich' >> Subject: RE: [Exist-open] weird behaviour between two XQueries that should >> dothe same >> >> I'm absolutely no XQuery expert but wouldn't it be easier to get the >> pricing >> nodes like this: >> >> let $results := >> collection("/db/results/")/pricing[results/result[@type='value' and >> @name='mtm']] >> >> (probably missing something here) >> gary >> >>> -----Original Message----- >>> From: exi...@li... [mailto:exist-open- >>> bo...@li...] On Behalf Of Raul Davidovich >>> Sent: Wednesday, August 15, 2007 12:42 PM >>> To: exi...@li... >>> Subject: [Exist-open] weird behaviour between two XQueries that should >>> dothe same >>> >>> Hello, >>> >>> I'm experimenting a weird behaviour between two XQueries that do the >>> saem >>> thing. >>> They get a collection, iterate over the nodes, get the parent's parent >>> node, and create a result. >>> In the first one, I'm using the xpath >>> $pricing/input/requests/request[@type='value' and @name='mtm']/shift >>> inline in the construction of the result, in the second one I'm defining >>> a >>> variable with it. Both get executed inside the loop. >>> The first one seems to get the result for this XPath from the retrieved >>> collection, whereas the second one seems to be querying the database >>> again >>> (the logs show it cannot find an index for it once for each iteration in >>> the loop) >>> >>> >>> The first one takes 3687 ms to execute, the second one 243917 ms. >>> >>> >>> Here is the code and the traces: >>> >>> >>> xquery version "1.0"; >>> declare namespace tools="java:test.XQuery"; >>> >>> let $resultdoc := document{ >>> <results> >>> { >>> let $results := >>> collection("/db/results/")/pricing/results/result[@type='value' and >>> @name='mtm'] >>> for $result in $results >>> let $pricing :=$result/ancestor::node()/ancestor::node() >>> return( >>> <result>{concat($pricing/@id,",",$pricing/input/user,",",1,",",0,"," >>> ,",",tools:normalise(tools:round($result,9),$pricing/input/requests/reques >>> t[@type='value' >>> and @name='mtm']/shift))}</result> >>> ) >>> } >>> </results> >>> } >>> >>> for $line in $resultdoc/results/result >>> return $line/text() >>> >>> >>> >>> 2007-08-15 17:31:04,822 DEBUG [main] xquery.XQuery (XQuery.java:156) - >>> Compilation took 156 >>> 2007-08-15 17:31:04,838 DEBUG [main] xmldb.LocalXPathQueryService >>> (LocalXPathQueryService.java:226) - compilation took 438 >>> 2007-08-15 17:31:05,369 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:407) - found an index of type: xs:string >>> 2007-08-15 17:31:05,369 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:452) - Checking if range index can be used for >>> key: value >>> 2007-08-15 17:31:05,384 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:457) - Using range index for key: value >>> 2007-08-15 17:31:05,525 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:407) - found an index of type: xs:string >>> 2007-08-15 17:31:05,525 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:452) - Checking if range index can be used for >>> key: mtm >>> 2007-08-15 17:31:05,525 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:457) - Using range index for key: mtm >>> 2007-08-15 17:31:08,259 DEBUG [main] storage.NativeBroker >>> (NativeBroker.java:660) - Creating collection '/db/system/temp'... >>> 2007-08-15 17:31:08,291 DEBUG [main] >>> collections.CollectionConfigurationManager >>> (CollectionConfigurationManager.java:165) - Reading collection >>> configuration for '/db/system/temp' from index configuration >>> 2007-08-15 17:31:08,447 DEBUG [main] storage.CacheManager >>> (CacheManager.java:180) - Growing cache elements.dbx (a >>> org.exist.storage.cache.LRUCache) from 64 to 80 >>> 2007-08-15 17:31:08,447 DEBUG [main] xquery.XQueryContext >>> (XQueryContext.java:1634) - Stored: 3462: >>> /db/system/temp/352e01d0f21fe847a2aa460ebaff055a.xml >>> 2007-08-15 17:31:08,509 DEBUG [main] util.HTTPUtils (HTTPUtils.java:61) >>> - >>> mostRecentDocumentTime: 1187195468259 >>> 2007-08-15 17:31:08,525 DEBUG [main] xmldb.LocalXPathQueryService >>> (LocalXPathQueryService.java:374) - query took 3687 ms. >>> >>> >>> ---------------------------------- >>> ################# >>> --------------------------------- >>> >>> >>> >>> xquery version "1.0"; >>> declare namespace tools="java:test.XQuery"; >>> >>> let $resultdoc := document{ >>> <results> >>> { >>> let $results := >>> collection("/db/results/")/pricing/results/result[@type='value' and >>> @name='mtm'] >>> for $result in $results >>> let $pricing :=$result/ancestor::node()/ancestor::node() >>> let $shift := $pricing/input/requests/request[@type='value' >>> and >>> @name='mtm']/shift >>> return( >>> <result>{concat($pricing/@id,",",$pricing/input/user,",",1,",",0,"," >>> ,",",tools:normalise(tools:round($result,9),$shift))}</result> >>> ) >>> } >>> </results> >>> } >>> >>> for $line in $resultdoc/results/result >>> return $line/text() >>> >>> >>> >>> >>> >>> 2007-08-15 17:33:25,741 DEBUG [main] xquery.XQuery (XQuery.java:156) - >>> Compilation took 156 >>> 2007-08-15 17:33:25,741 DEBUG [main] xmldb.LocalXPathQueryService >>> (LocalXPathQueryService.java:226) - compilation took 422 >>> 2007-08-15 17:33:26,304 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:407) - found an index of type: xs:string >>> 2007-08-15 17:33:26,304 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:452) - Checking if range index can be used for >>> key: value >>> 2007-08-15 17:33:26,304 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:457) - Using range index for key: value >>> 2007-08-15 17:33:26,444 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:407) - found an index of type: xs:string >>> 2007-08-15 17:33:26,444 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:452) - Checking if range index can be used for >>> key: mtm >>> 2007-08-15 17:33:26,444 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:457) - Using range index for key: mtm >>> 2007-08-15 17:33:26,616 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: value >>> 2007-08-15 17:33:26,616 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:33:26,647 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: mtm >>> 2007-08-15 17:33:26,647 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:33:26,725 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: value >>> 2007-08-15 17:33:26,725 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:33:26,725 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: mtm >>> 2007-08-15 17:33:26,725 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:33:26,788 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: value >>> 2007-08-15 17:33:26,788 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:33:26,804 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: mtm >>> 2007-08-15 17:33:26,804 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> >>> >>> ... (thousands of times) >>> >>> >>> 2007-08-15 17:37:29,299 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: value >>> 2007-08-15 17:37:29,299 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:37:29,315 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:518) - No suitable index found for key: mtm >>> 2007-08-15 17:37:29,315 TRACE [main] xquery.GeneralComparison >>> (GeneralComparison.java:301) - No index: fall back to nodeSetCompare >>> 2007-08-15 17:37:29,361 DEBUG [main] storage.NativeBroker >>> (NativeBroker.java:660) - Creating collection '/db/system/temp'... >>> 2007-08-15 17:37:29,377 DEBUG [main] >>> collections.CollectionConfigurationManager >>> (CollectionConfigurationManager.java:165) - Reading collection >>> configuration for '/db/system/temp' from index configuration >>> 2007-08-15 17:37:29,549 DEBUG [main] xquery.XQueryContext >>> (XQueryContext.java:1634) - Stored: 3462: >>> /db/system/temp/1e0e1e578aa1b0f850cd2f5746d4cef2.xml >>> 2007-08-15 17:37:29,658 DEBUG [main] util.HTTPUtils (HTTPUtils.java:61) >>> - >>> mostRecentDocumentTime: 1187195849361 >>> 2007-08-15 17:37:29,658 DEBUG [main] xmldb.LocalXPathQueryService >>> (LocalXPathQueryService.java:374) - query took 243917 ms. >>> >>> >>> >>> Any clues? >>> >>> >>> Many thanks and best regards, >>> >>> Raul >>> >>> >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by: Splunk Inc. >>> Still grepping through log files to find problems? Stop. >>> Now Search log events and configuration files using AJAX and a browser. >>> Download your FREE copy of Splunk now >> http://get.splunk.com/ >>> _______________________________________________ >>> Exist-open mailing list >>> Exi...@li... >>> https://lists.sourceforge.net/lists/listinfo/exist-open >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. >> Still grepping through log files to find problems? Stop. >> Now Search log events and configuration files using AJAX and a browser. >> Download your FREE copy of Splunk now >> http://get.splunk.com/ >> _______________________________________________ >> Exist-open mailing list >> Exi...@li... >> https://lists.sourceforge.net/lists/listinfo/exist-open >> |