Changes

Jump to navigation Jump to search
169 bytes added ,  13:35, 7 January 2019
=Execution=
Asynchronous query execution is recommendable if There are cases in which a client does not, or cannot, wait until a request is fully processed. This is e. g. the case with web browsersThe client may be a browser, which will usually cancel a sends an HTTP request after a specific timeout. In such cases, you can use asynchronous execution to trigger another the server-side process, which will in order to start the another time-consuming processquery job. The functions in this section allow you to register a new query job from a running query. Jobs can be executed immediately (i.e., and fetch the result later on as soon as the [[Transaction Management#Concurrency Control|Concurrency Control]] allows it is available) or scheduled for repeated execution. Each registered job gets a job id, and the id can be used to retrieve a query result, stop a job, or wait for its termination.
==jobs:eval==
};
</pre>
* The following query demonstrates how the results of an asynchronously executed query can be returned within the same query(see below why you should avoid this pattern in practice):
<pre class='brush:xquery'>
let $query := jobs:eval('(1 to 10000000)[. = 1]', map{}, map{ 'cache': true() })
return (
jobs:wait($query),
)
</pre>
Please note that queries Queries of this kind can cause deadlocks. For example, if both ! If the original query and the new query to be executed asynchronously perform updates on the same database, the second query would will only be run after the first one has been executed, and the first query will wait for the second query forever. This is why you You should avoid this pattern in practice and resort to [[XQuery Module#xquery:fork-join|xquery:fork-join]] if you want to do things in have full control on parallelquery execution.
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu