
Real database swords - globals - have long been known, but so far few are able to use them effectively or do not own this super-weapon at all.
If you use globals in solving the problems in which they are really good, you can achieve outstanding results. Either in performance or in simplifying the solution of the problem (
1 ,
2 ).
Globals are a special way of storing and processing data, completely different than tables in SQL. They appeared in 1966 in the
M language
(UMPS) (evolutionary development -
Caché ObjectScript , then COS) in medical databases and are still
actively used there , and also penetrated into some other areas where reliability and high performance are required: finance, trading etc.
')
Globals in modern DBMS support transactions, logging, replication, partitioning. Those. they can build modern, reliable, distributed and fast systems.
Globals do not limit you to the relational model. They give the freedom to develop data structures optimized for specific tasks. For many applications, wise use of globals can be a truly secret weapon, providing performance that relational application developers can only dream of.
Globals as a data storage method can be used in many modern programming languages, both high-level and low-level. Therefore, in this article, I will focus on globala, and not on the language from which they once came out.
2. How do globals work?
Let's first understand how globals work, and what are their strengths. You can look at globals from different points of view. In this part of the article, we will look at them like trees. Or as a hierarchical data warehouse.
Simply put, global is a persistent array. An array that is automatically saved to disk.
It’s hard to imagine something simpler to store data. In the code (in COS / M languages), it differs from the usual associative array only by the
^ character in front of the name.
To save data in the global there is no need to learn the SQL query language, the commands for working with them are very simple. They can be learned in an hour.
Let's start with the simplest example. A single-level tree with 2 branches. The examples are written in COS.

Set ^a("+7926X") = "John Sidorov"
Set ^a("+7916Y") = "Sergey Smith"
(a Set) 3 :
- .
- . ( — «subscript»), — («node value»).
- . . «Sergey Smith», «John Sidorov». . , , ( , ).
. 750 000 / .
/.
, . , , —
Visa. , .

.
Set ^a("+7926X", "city") = "Moscow"
Set ^a("+7926X", "city", "street") = "Req Square"
Set ^a("+7926X", "age") = 25
Set ^a("+7916Y", "city") = "London"
Set ^a("+7916Y", "city", "street") = "Baker Street"
Set ^a("+7916Y", "age") = 36

, . - . .
, . ( )
511 ,
3.6 Caché. ( ) — 31.
. , .

Set ^b("a", "b", "c", "d") = 1
Set ^b("a", "b", "c", "e") = 2
Set ^b("a", "b", "f", "g") = 3
— , .
, , : .
: , , .

.
— , .
.

:
- : , .
- : , — .
, , . .. .
.
, , ?
- , .
- . . , .

- README.txt, , . . , .
- . , (1, 2). , , . , 1 96-341 HDD ( SSD). , .
— . . .
Kill.
Kill ^a("+7926X")

, , .
, .
Disclaimer:
InterSystems.— - . . 2. .