5.10 Temporary Documents

see Read-only versus Updatable

WARNING: the use case of serving out small parts of a large results is now better covered using the see Session Expression Cache.

One of the interesting uses of fn:put() (see The put() Function) is to cache intermediate results produced by a costly query. For instance, a GUI that shows some result table, may be able to show a limited amount of results on the screen and provide a scroll-bar to go up or down in the result list. Instead of recomputing the query result every time the scroll-bar is moved, an application can use fn:put() to serialize the query result in some temporary location TMP, and then use fn:subsequence(doc('TMP')) to show slices of it.

The question then arises where temporary files can be stored conveniently, and how they will be garbage collected. For this purpose, MonetDB/XQuery offers the tmp/ directory (that is, the <gdk_dbfarm>/<dbname>/tmp directory). The MonetDB/XQuery server monitors this directory continuously, making sure that files that are older than one hour are deleted automatically. This simple mechanism makes it easy for e.g. web applications to use temporary XML, without having to resort to a stateful client-server protocol (e.g. a session object that would perform temporary XML cleanup at session end).

Of course, your disk should have enough space for one hour of produced temporary results, otherwise disk-full errors may occur. Use this feature with care.