|
|
|||
2.9.5 Expression CachingExpression Caching is a powerful feature to create well-performing functionally rich applications. You can use it for query result caching (avoiding to compute the same query twice), as a mechanism to simulate cursors; allowing an expensive query that delivers large result to be evaluated once, allowing subsequent queries to show small parts of a result set, that eg fit on the screen. The mechanism allows Caching of Arbitrary Subexpressions inside a so-called Multi-Query Session. To profit from these, one should restructure the data access of applications to use the same database snapshot for multiple queries (with a long enough timeout to be sure the session stays alive in the cache). As a second step, the XQuery queries should be analyzed and interesting expressions could be marked up. The marked up expressions are cached; if a query find them already cached, the result is available instantly. One typical use of subexpression caching is skipping quickly paging
back and forth through a large query result (what SQL users use "cursors" for),
e.g. showing the elements in range (# pf:session my-own-id:30000 #) {
subsequence((# pf:cache my-male-persons #) { doc("auctions.xml)//person[gender = "male"] }, LO, HI)
}
Note the entire query is wrapped in a The in-session subexpression caching mechanism described in detail in see Session Expression Cache. |
||||
| © 1994-2011 CWI | Contact us Legal HG web Bugs TestWeb | |||