Temporary Globals and the IRISTEMP Database
For some operations, you may need the power of globals without requiring the data to be saved indefinitely. For example, you may want to use a global to sort some data which you do not need to store to disk. For these operations, InterSystems IRIS provides the mechanism of temporary globals
. This mechanism works as follows:
For your application namespace, you define a global mapping so that globals with a specific naming convention are to be mapped to the IRISTEMP
database, which is a special database as discussed below.
For example, you might define a global mapping so that all globals with names of the form ^AcmeTemp*
are mapped to the IRISTEMP
When your code needs to store data temporarily and read it again, your code writes to and reads from globals that use that naming convention.
For example, to save a value, your code might do this:
set ^AcmeTempOrderApp("sortedarray")=some value
Then later your code might do this:
set somevariable = ^AcmeTempOrderApp("sortedarray")
By using temporary globals, you take advantage of the fact that the IRISTEMP
database is not journaled
. Because the database is not journaled, operations that use the database do not result in journal files. Journal files can become large and can cause space issues. However, note the following points:
You cannot roll back any transactions that modify globals in the IRISTEMP
database; this behavior is specific to IRISTEMP
. If you need to manage temporary work via transactions, do not use globals in IRISTEMP
for that purpose.
Take care to use IRISTEMP
only for work that does not need to be saved.
To define a mapping for temporary globals, do the following:
Choose a naming convention and ensure that all of your developers are aware of it. Note the following points:
Consider whether to have many temporary globals or fewer temporary globals with multiple nodes. It is easier for InterSystems IRIS to efficiently read or write different nodes within the same global, compared to reading or writing the equivalent number of separate globals. The efficiency difference is negligible for small numbers of globals but is noticeable when there are hundreds of separate globals.
If you plan to use the same global mapping in multiple namespaces, then devise a system so that work in one namespace does not interfere with work in another namespace. For example, you could use the namespace name as a subscript in the globals.
Similarly, even within one namespace, devise a system so that each part of the code uses a different global or a different subscript in the same global, again to avoid interference.
For Global name
, enter a name ending in an asterisk (*
). Do not include the initial caret of the name.
This mapping causes all globals with names that start AcmeTemp*
to be mapped to the IRISTEMP
displayed in the first column of the new mappings row indicates that you opened the mapping for editing.
To save the mappings so that InterSystems IRIS uses them, click Save Changes
Note that InterSystems uses temporary globals as scratch space for optimizing SQL complex queries and for other purposes. It may also uses temporary globals as temporary indices during the execution of certain queries (for sorting, grouping, calculating aggregates, etc.)
Some of the system globals contained in IRISTEMP
Never change any of these globals.
Content Date/Time: 2019-02-22 22:51:54