Globals QuickStart

10 minutes

InterSystems IRIS™ data platform contains an extremely efficient data model known as globals. Individually, a global is a persistent multidimensional array. Data added to globals is immediately stored and available to multiple processes, not just the process that stored it.

The benefits of using globals are vast. Globals are:

  • Efficient: They grow based on need, without upfront declaration of size or structure.
  • Multi-model: They store objects, tables and indexes, JSON and XML documents, even documentation.
  • Typeless: They can contain integer, named, or any other subscript type, even at the same subscript level.
  • Automatically sorted: They sort subscripts automatically at each dimension.
  • Flexible: They allow flexibility in node structure and data storage to contain any number of subscripts and any type of data.
  • Safe: You can lock any node to keep other processes from changing value, while keeping other nodes at same level accessible.

Note that globals are not just another storage model. In fact, they are so powerful and flexible that they are actually at the core of all InterSystems models, giving you freedom from database remodels.

Interested in seeing it for yourself? Check out the exercise below.

If you don’t have InterSystems IRIS set up yet, get a free development sandbox here.


  1. Verify you have an instance of InterSystems IRIS, and an IDE that supports Java (such as Eclipse). If you are using AWS, Azure, or GCP, verify that you have followed the steps to change the password for InterSystems IRIS.

Globals’ typeless nodes provide great flexibility

  1. Open the InterSystems Terminal.
    Opening the IRIS Terminal
    • Learning Labs Sandbox: from the InterSytems menu, select InterSystems IRIS Terminal
    • Docker-based: from the container host’s shell, use the command docker exec -it try-iris iris terminal <IRIS instance name>

    Create the following globals (Hint: You can copy all lines at once and paste!):
    set ^Stock("dress", 4, "blue", "floral") = 52
    set ^Stock("dress", 8, "green", "solid") = 10
    set ^Stock("dress", 4, "blue", "striped") = 7
    set ^Stock("dress", 4, "blue", "solid") = 117
    set ^Stock("dress", "location") = "aisle A"

    Here, you are storing this data directly to InterSystems IRIS in your own custom structure. This example contains one node for each pattern and an additional node for the location of the dresses in the store. Notice the subscripts within a global ("dress" and 4) can have different types. Furthermore, subscripts even within the same position (4 and "location") can also have different types, supporting your ability to dynamically and efficiently store sparse and varied data.

Globals are automatically sorted and easy to retrieve

  1. To easily see if there are any size 4 blue dresses with a floral pattern, you can access the correct data node by executing:
    write ^Stock("dress", 4, "blue", "floral")
  2. This data is automatically sorted and easy to filter. View globals of only size 4 dresses, automatically sorted, by entering into Terminal:
    zwrite ^Stock("dress",4)

Globals are easy and performant

  1. Display the amount in stock of all size 4 blue dresses simply by iterating through all of the data nodes below the ^Stock("dress", 4, "blue") node.
  2. Copy and paste the following line and execute it in Terminal:
    set key = "" for { set key =
    $order(^Stock("dress",4,"blue",key)) quit:key="" write !
    ,key_":"_$get(^Stock("dress",4,"blue",key)) }
  3. Unrelated nodes, such as the location of dresses, are not touched, optimizing the performance of the retrieval. Note that while you can run this in one line, a slightly more formatted version of this breaks down the key aspects of this code:
  4. To exit the InterSystems Terminal, type halt.
Up Next
Globals Deep Dive
10 minutes