multithreading - Task server on ML -
i have query may return 2000 documents. within these documents need 6 pcdata items return string values. there possiblity, since documents size range small large, exp tree cache error.
i looking @ spawn-function break result set. pass wildcard values, based on known "unique key structure", , know max number of results possible;each wildcard values return 100 documents max. note: pcdata unique key structure have range index on it.
am on right track below? task server create 3 tasks. task server allow multiple queries run, stops them running simultaneously , blowing out exp tree cache? i.e. what, if anything, forces 1 thread wait another? or 1 task wait not blow out exp tree cache together?
xquery version "1.0-ml"; let $messages := (:each wildcard values return 100 documents max:) $message in ("wildcardval1","wildcardval2", "wildcardval3") let $_ := xdmp:log("starting") return xdmp:spawn-function(function() { let $_ := xdmp:sleep(5000) let $_ := xdmp:log(concat("searching on wildcard val=", $message)) return concat("100 pcdata items matched documents ", $message) }, <options xmlns="xdmp:eval"> <result>true</result> <transaction-mode>update-auto-commit</transaction-mode> </options>) return $messages
the task server configuration listed in admin ui defines maximum number of simultaneous threads. if more tasks spawned there threads, queued (fifo think, although ml9 has task priority options modify behavior), , first queued task takes next available thread.
the <result>true</result> option force spawning query block until tasks return. tasks run independently , in parallel, , don't wait on each other finish. may still run problems expanded tree cache, splitting query smaller ones, less likely.
for better understanding of why blowing out cache, take @ functions xdmp:query-trace() , xdmp:query-meters(). using task server more of brute force solution, , better results optimizing queries using information functions.
if can't make query more selective 2000 documents, need few string values, consider creating range indexes on values , using cts:values select values directly index, filtered query. method avoid forcing database load documents cache.
Comments
Post a Comment