Queries

A query is a document that reads facts and gives rows. It writes nothing. A query needs find, and most queries add where.

Query execution measures CPU work on its thread, in 100-nanosecond ticks. Its budget includes planning, scans, expressions and result construction. Bounds describes the limits. The public API returns rows. Optional explain records give measurements for individual calls.

The examples with result blocks read these five entities. This merge patch creates them in a fresh database: Ada has ID 1, Bob 2, Cy 3, Dan 4 and Eve 5. The returned commit records these IDs for the patch's temporary names.

TRON768 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0046C 73616C617279txt "salary"
00B02 78000000000000 00i64 120
0140F 0A 04000000 0B00 0000map leaf, size 10: @4 → @B
01E3C 616765txt "age"
02202 24000000000000 00i64 36
02B0F 0A 1E000000 2200 0000map leaf, size 10: @1E → @22
0354C 726F6C65txt "role"
03A8C 656E67696E6565 72txt "engineer"
0430F 0A 35000000 3A00 0000map leaf, size 10: @35 → @3A
04D4C 64657074txt "dept"
0523C 656E67txt "eng"
0560F 0A 4D000000 5200 0000map leaf, size 10: @4D → @52
06007 0E 20080000 4300 0000 56000000map branch, size 14, depth 1, slots 5, 11: @43 → @56
06E4C 6E616D65txt "name"
0733C 416461txt "Ada"
0770F 0A 6E000000 7300 0000map leaf, size 10: @6E → @73
08107 16 10910000 1400 0000 2B000000 6000 0000 77000000map branch, size 22, depth 0 (root), slots 4, 8, 12, 15: @14 → @2B → @60 → @77
0975C 236C696E6Btxt "#link"
09D5C 235F616461txt "#_ada"
0A30F 0A 97000000 9D00 0000map leaf, size 10: @97 → @9D
0AD6C 73616C617279txt "salary"
0B402 64000000000000 00i64 100
0BD0F 0A AD000000 B400 0000map leaf, size 10: @AD → @B4
0C73C 616765txt "age"
0CB02 29000000000000 00i64 41
0D40F 0A C7000000 CB00 0000map leaf, size 10: @C7 → @CB
0DE6C 6D656E746F72txt "mentor"
0E50F 0A DE000000 A300 0000map leaf, size 10: @DE → @A3
0EF4C 726F6C65txt "role"
0F48C 656E67696E6565 72txt "engineer"
0FD0F 0A EF000000 F400 0000map leaf, size 10: @EF → @F4
Show all 87 nodes
Offset (hex)Bytes (hex)Meaning
1074C 64657074txt "dept"
10C3C 656E67txt "eng"
1100F 0A 07010000 0C01 0000map leaf, size 10: @107 → @10C
11A07 0E 20080000 FD00 0000 10010000map branch, size 14, depth 1, slots 5, 11: @FD → @110
1284C 6E616D65txt "name"
12D3C 426F62txt "Bob"
1310F 0A 28010000 2D01 0000map leaf, size 10: @128 → @12D
13B07 1A 10990000 BD00 0000 D4000000 E500 0000 1A010000 3101 0000map branch, size 26, depth 0 (root), slots 4, 8, 11, 12, 15: @BD → @D4 → @E5 → @11A → @131
1556C 73616C617279txt "salary"
15C02 5A000000000000 00i64 90
1650F 0A 55010000 5C01 0000map leaf, size 10: @155 → @15C
16F3C 616765txt "age"
17302 1D000000000000 00i64 29
17C0F 0A 6F010000 7301 0000map leaf, size 10: @16F → @173
1864C 726F6C65txt "role"
18B8C 64657369676E65 72txt "designer"
1940F 0A 86010000 8B01 0000map leaf, size 10: @186 → @18B
19E4C 64657074txt "dept"
1A35C 73616C6573txt "sales"
1A90F 0A 9E010000 A301 0000map leaf, size 10: @19E → @1A3
1B307 0E 20080000 9401 0000 A9010000map branch, size 14, depth 1, slots 5, 11: @194 → @1A9
1C14C 6E616D65txt "name"
1C62C 4379txt "Cy"
1C90F 0A C1010000 C601 0000map leaf, size 10: @1C1 → @1C6
1D307 16 10910000 6501 0000 7C010000 B301 0000 C9010000map branch, size 22, depth 0 (root), slots 4, 8, 12, 15: @165 → @17C → @1B3 → @1C9
1E96C 73616C617279txt "salary"
1F002 46000000000000 00i64 70
1F90F 0A E9010000 F001 0000map leaf, size 10: @1E9 → @1F0
2034C 64657074txt "dept"
2085C 73616C6573txt "sales"
20E0F 0A 03020000 0802 0000map leaf, size 10: @203 → @208
2184C 6E616D65txt "name"
21D3C 44616Etxt "Dan"
2210F 0A 18020000 1D02 0000map leaf, size 10: @218 → @21D
22B07 12 10900000 F901 0000 0E020000 2102 0000map branch, size 18, depth 0 (root), slots 4, 12, 15: @1F9 → @20E → @221
23D6C 73616C617279txt "salary"
24402 50000000000000 00i64 80
24D0F 0A 3D020000 4402 0000map leaf, size 10: @23D → @244
2574C 64657074txt "dept"
25C3C 6F7073txt "ops"
2600F 0A 57020000 5C02 0000map leaf, size 10: @257 → @25C
26A4C 6E616D65txt "name"
26F3C 457665txt "Eve"
2730F 0A 6A020000 6F02 0000map leaf, size 10: @26A → @26F
27D07 12 10900000 4D02 0000 60020000 7302 0000map branch, size 18, depth 0 (root), slots 4, 12, 15: @24D → @260 → @273
28F5C 235F64616Etxt "#_dan"
2950F 0A 8F020000 2B02 0000map leaf, size 10: @28F → @22B
29F4C 235F6379txt "#_cy"
2A40F 0A 9F020000 D301 0000map leaf, size 10: @29F → @1D3
2AE5C 235F626F62txt "#_bob"
2B40F 0A AE020000 3B01 0000map leaf, size 10: @2AE → @13B
2BE5C 235F657665txt "#_eve"
2C40F 0A BE020000 7D02 0000map leaf, size 10: @2BE → @27D
2CE5C 235F616461txt "#_ada"
2D40F 0A CE020000 8100 0000map leaf, size 10: @2CE → @81
2DE07 1A 82310000 9502 0000 A4020000 B402 0000 C4020000 D402 0000map branch, size 26, depth 0 (root), slots 1, 7, 8, 12, 13: @295 → @2A4 → @2B4 → @2C4 → @2D4
Offset (hex)Bytes (hex)Meaning

Find and where

find gives the columns. where gives the clauses that bind them. A variable that appears in more than one clause joins those clauses.

TRON253 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A4C 3F73616Ctxt "?sal"
0F0E 11 00 0300 020000 00 04000000 0A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A
202C 3F65txt "?e"
234C 64657074txt "dept"
285C 3F64657074txt "?dept"
2E0E 15 00 0700 030000 00 20000000 230000 00 28000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @20 → @23 → @28
432C 3F65txt "?e"
466C 73616C617279txt "salary"
4D4C 3F73616Ctxt "?sal"
520E 15 00 0700 030000 00 43000000 460000 00 4D000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @43 → @46 → @4D
672C 3F65txt "?e"
6A4C 6E616D65txt "name"
6F5C 3F6E616D65txt "?name"
750E 15 00 0700 030000 00 67000000 6A0000 00 6F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @67 → @6A → @6F
8A0E 15 00 0700 030000 00 2E000000 520000 00 75000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @2E → @52 → @75
9F5C 3F6E616D65txt "?name"
A50E 0D 00 0100 010000 00 9F000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @9F
B25C 7768657265txt "where"
B80F 0A B2000000 8A00 0000map leaf, size 10: @B2 → @8A
C24C 66696E64txt "find"
C70F 0A C2000000 0F00 0000map leaf, size 10: @C2 → @F
D17C 6F726465724279txt "orderBy"
D90F 0A D1000000 A500 0000map leaf, size 10: @D1 → @A5
E307 12 2A000000 B800 0000 C7000000 D900 0000map branch, size 18, depth 0 (root), slots 1, 3, 5: @B8 → @C7 → @D9
TRON320 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0043C 73616Ctxt "sal"
00802 78000000000000 00i64 120
0110F 0A 04000000 0800 0000map leaf, size 10: @4 → @8
01B4C 6E616D65txt "name"
0203C 416461txt "Ada"
0240F 0A 1B000000 2000 0000map leaf, size 10: @1B → @20
02E07 0E 80800000 1100 0000 24000000map branch, size 14, depth 0 (root), slots 7, 15: @11 → @24
03C3C 73616Ctxt "sal"
04002 64000000000000 00i64 100
0490F 0A 3C000000 4000 0000map leaf, size 10: @3C → @40
0534C 6E616D65txt "name"
0583C 426F62txt "Bob"
05C0F 0A 53000000 5800 0000map leaf, size 10: @53 → @58
06607 0E 80800000 4900 0000 5C000000map branch, size 14, depth 0 (root), slots 7, 15: @49 → @5C
0743C 73616Ctxt "sal"
07802 5A000000000000 00i64 90
0810F 0A 74000000 7800 0000map leaf, size 10: @74 → @78
08B4C 6E616D65txt "name"
0902C 4379txt "Cy"
0930F 0A 8B000000 9000 0000map leaf, size 10: @8B → @90
09D07 0E 80800000 8100 0000 93000000map branch, size 14, depth 0 (root), slots 7, 15: @81 → @93
0AB3C 73616Ctxt "sal"
0AF02 46000000000000 00i64 70
0B80F 0A AB000000 AF00 0000map leaf, size 10: @AB → @AF
0C24C 6E616D65txt "name"
0C73C 44616Etxt "Dan"
0CB0F 0A C2000000 C700 0000map leaf, size 10: @C2 → @C7
0D507 0E 80800000 B800 0000 CB000000map branch, size 14, depth 0 (root), slots 7, 15: @B8 → @CB
0E33C 73616Ctxt "sal"
0E702 50000000000000 00i64 80
0F00F 0A E3000000 E700 0000map leaf, size 10: @E3 → @E7
0FA4C 6E616D65txt "name"
0FF3C 457665txt "Eve"
1030F 0A FA000000 FF00 0000map leaf, size 10: @FA → @FF
10D07 0E 80800000 F000 0000 03010000map branch, size 14, depth 0 (root), slots 7, 15: @F0 → @103
11B0E 1D 00 1F00 050000 00 2E000000 660000 00 9D000000 D50000 00 0D010000array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @2E → @66 → @9D → @D5 → @10D

Clauses

A where clause has one of these forms.

KindShapePurpose
Fact[?e field ?v]Matches stored facts
Member[member ?e field ?key ?v]Matches members of an object field
Negation[not [...]]Drops each solution that matches inside
Predicate[> ?v 5]Keeps each solution the expression accepts
Derivation[[expression] ?out]Binds a calculated value to a new variable
Schema[schema name ?e]Keeps entities that match a stored schema

A fact clause has an entity, a field and a value. Each position accepts a variable, a literal, or _ for a position that you do not read. An entity position also accepts an entity reference such as {#link 1}, the id of that entity. A fourth term binds the transaction of the fact.

A member clause reads each immediate member of an object field. It binds the member name as a string and the member value as stored. A sixth term can bind the transaction of the field.

TRON164 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 3F6B6579txt "?key"
097C 3F617274697374txt "?artist"
110E 11 00 0300 020000 00 04000000 090000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @9
226C 6D656D626572txt "member"
296C 3F747261636Btxt "?track"
307C 61727469737473txt "artists"
384C 3F6B6579txt "?key"
3D7C 3F617274697374txt "?artist"
450E 1D 00 1F00 050000 00 22000000 290000 00 30000000 380000 00 3D000000array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @22 → @29 → @30 → @38 → @3D
620E 0D 00 0100 010000 00 45000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @45
6F5C 7768657265txt "where"
750F 0A 6F000000 6200 0000map leaf, size 10: @6F → @62
7F4C 66696E64txt "find"
840F 0A 7F000000 1100 0000map leaf, size 10: @7F → @11
8E07 0E 0A000000 7500 0000 84000000map branch, size 14, depth 0 (root), slots 1, 3: @75 → @84

For example, this field has one member. Its name is a MusicBrainz GID. Its value is a link to artist entity 8306.

TRON99 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 236C696E6Btxt "#link"
0A02 72200000000000 00i64 8306
130F 0A 04000000 0A00 0000map leaf, size 10: @4 → @A
1D14 20 616631653736 6630363238363463 6434623439383961 3732613864663764 6531txt "af1e76f062864cd4b4989a72…"
3F0F 0A 1D000000 1300 0000map leaf, size 10: @1D → @13
497C 61727469737473txt "artists"
510F 0A 49000000 3F00 0000map leaf, size 10: @49 → @3F

If you do not need the member name, use _. A bound link value and a known field use the reference index for current reads. The engine then checks the current object to exclude removed or changed links.

TRON285 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0046C 3F7469746C65txt "?title"
00B0E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
0187C 3F617274697374txt "?artist"
0204C 6E616D65txt "name"
025BC 4A6F686E204C65 6E6E6F6Etxt "John Lennon"
0310E 15 00 0700 030000 00 18000000 200000 00 25000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @18 → @20 → @25
0466C 6D656D626572txt "member"
04D6C 3F747261636Btxt "?track"
0547C 61727469737473txt "artists"
05C1C 5Ftxt "_"
05E7C 3F617274697374txt "?artist"
0660E 1D 00 1F00 050000 00 46000000 4D0000 00 54000000 5C0000 00 5E000000array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @46 → @4D → @54 → @5C → @5E
0836C 3F747261636Btxt "?track"
08A5C 747261636Btxt "track"
0901C 5Ftxt "_"
0920E 15 00 0700 030000 00 83000000 8A0000 00 90000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @83 → @8A → @90
0A76C 3F747261636Btxt "?track"
0AE4C 6E616D65txt "name"
0B36C 3F7469746C65txt "?title"
0BA0E 15 00 0700 030000 00 A7000000 AE0000 00 B3000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @A7 → @AE → @B3
0CF0E 19 00 0F00 040000 00 31000000 660000 00 92000000 BA0000 00array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @31 → @66 → @92 → @BA
0E85C 7768657265txt "where"
0EE0F 0A E8000000 CF00 0000map leaf, size 10: @E8 → @CF
0F84C 66696E64txt "find"
0FD0F 0A F8000000 0B00 0000map leaf, size 10: @F8 → @B
10707 0E 0A000000 EE00 0000 FD000000map branch, size 14, depth 0 (root), slots 1, 3: @EE → @FD

Member clauses accept objects. Arrays and tagged scalar values have no matching members. Two keys with the same value produce two matches. Use distinct true to remove repeated result rows. An ordinary fact clause still reads the complete field value.

A negation drops each solution that matches the clause inside it.

TRON223 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A0E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
172C 3F65txt "?e"
1A4C 6E616D65txt "name"
1F5C 3F6E616D65txt "?name"
250E 15 00 0700 030000 00 17000000 1A0000 00 1F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @17 → @1A → @1F
3A2C 3F65txt "?e"
3D4C 64657074txt "dept"
423C 656E67txt "eng"
460E 15 00 0700 030000 00 3A000000 3D0000 00 42000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3A → @3D → @42
5B3C 6E6F74txt "not"
5F0E 11 00 0300 020000 00 5B000000 460000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @5B → @46
700E 11 00 0300 020000 00 25000000 5F0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @25 → @5F
815C 3F6E616D65txt "?name"
870E 0D 00 0100 010000 00 81000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @81
945C 7768657265txt "where"
9A0F 0A 94000000 7000 0000map leaf, size 10: @94 → @70
A44C 66696E64txt "find"
A90F 0A A4000000 0A00 0000map leaf, size 10: @A4 → @A
B37C 6F726465724279txt "orderBy"
BB0F 0A B3000000 8700 0000map leaf, size 10: @B3 → @87
C507 12 2A000000 9A00 0000 A9000000 BB00 0000map branch, size 18, depth 0 (root), slots 1, 3, 5: @9A → @A9 → @BB
TRON89 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 6E616D65txt "name"
092C 4379txt "Cy"
0C0F 0A 04000000 0900 0000map leaf, size 10: @4 → @9
164C 6E616D65txt "name"
1B3C 44616Etxt "Dan"
1F0F 0A 16000000 1B00 0000map leaf, size 10: @16 → @1B
294C 6E616D65txt "name"
2E3C 457665txt "Eve"
320F 0A 29000000 2E00 0000map leaf, size 10: @29 → @2E
3C0E 15 00 0700 030000 00 0C000000 1F0000 00 32000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @C → @1F → @32

A predicate keeps each solution that its expression accepts.

TRON246 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A0E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
172C 3F65txt "?e"
1A6C 73616C617279txt "salary"
214C 3F73616Ctxt "?sal"
260E 15 00 0700 030000 00 17000000 1A0000 00 21000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @17 → @1A → @21
3B2C 3F65txt "?e"
3E4C 6E616D65txt "name"
435C 3F6E616D65txt "?name"
490E 15 00 0700 030000 00 3B000000 3E0000 00 43000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3B → @3E → @43
5E1C 3Etxt ">"
604C 3F73616Ctxt "?sal"
6502 55000000000000 00i64 85
6E0E 15 00 0700 030000 00 5E000000 600000 00 65000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @5E → @60 → @65
830E 15 00 0700 030000 00 26000000 490000 00 6E000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @26 → @49 → @6E
985C 3F6E616D65txt "?name"
9E0E 0D 00 0100 010000 00 98000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @98
AB5C 7768657265txt "where"
B10F 0A AB000000 8300 0000map leaf, size 10: @AB → @83
BB4C 66696E64txt "find"
C00F 0A BB000000 0A00 0000map leaf, size 10: @BB → @A
CA7C 6F726465724279txt "orderBy"
D20F 0A CA000000 9E00 0000map leaf, size 10: @CA → @9E
DC07 12 2A000000 B100 0000 C0000000 D200 0000map branch, size 18, depth 0 (root), slots 1, 3, 5: @B1 → @C0 → @D2
TRON89 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 6E616D65txt "name"
093C 416461txt "Ada"
0D0F 0A 04000000 0900 0000map leaf, size 10: @4 → @9
174C 6E616D65txt "name"
1C3C 426F62txt "Bob"
200F 0A 17000000 1C00 0000map leaf, size 10: @17 → @1C
2A4C 6E616D65txt "name"
2F2C 4379txt "Cy"
320F 0A 2A000000 2F00 0000map leaf, size 10: @2A → @2F
3C0E 15 00 0700 030000 00 0D000000 200000 00 32000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @D → @20 → @32

A derivation calculates a value and binds it to a new variable. The expression comes first, and the new variable follows it.

TRON283 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0045C 3F6E616D65txt "?name"
00A7C 3F646F75626C65txt "?double"
0120E 11 00 0300 020000 00 04000000 0A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A
0232C 3F65txt "?e"
0266C 73616C617279txt "salary"
02D4C 3F73616Ctxt "?sal"
0320E 15 00 0700 030000 00 23000000 260000 00 2D000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @23 → @26 → @2D
0472C 3F65txt "?e"
04A4C 6E616D65txt "name"
04F5C 3F6E616D65txt "?name"
0550E 15 00 0700 030000 00 47000000 4A0000 00 4F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @47 → @4A → @4F
06A1C 2Atxt "*"
06C4C 3F73616Ctxt "?sal"
07102 02000000000000 00i64 2
07A0E 15 00 0700 030000 00 6A000000 6C0000 00 71000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @6A → @6C → @71
08F7C 3F646F75626C65txt "?double"
0970E 11 00 0300 020000 00 7A000000 8F0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @7A → @8F
0A80E 15 00 0700 030000 00 32000000 550000 00 97000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @32 → @55 → @97
0BD5C 3F6E616D65txt "?name"
0C30E 0D 00 0100 010000 00 BD000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @BD
0D05C 7768657265txt "where"
0D60F 0A D0000000 A800 0000map leaf, size 10: @D0 → @A8
0E04C 66696E64txt "find"
0E50F 0A E0000000 1200 0000map leaf, size 10: @E0 → @12
0EF7C 6F726465724279txt "orderBy"
0F70F 0A EF000000 C300 0000map leaf, size 10: @EF → @C3
10107 12 2A000000 D600 0000 E5000000 F700 0000map branch, size 18, depth 0 (root), slots 1, 3, 5: @D6 → @E5 → @F7
TRON335 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0046C 646F75626C65txt "double"
00B02 F0000000000000 00i64 240
0140F 0A 04000000 0B00 0000map leaf, size 10: @4 → @B
01E4C 6E616D65txt "name"
0233C 416461txt "Ada"
0270F 0A 1E000000 2300 0000map leaf, size 10: @1E → @23
03107 0E 00A00000 1400 0000 27000000map branch, size 14, depth 0 (root), slots 13, 15: @14 → @27
03F6C 646F75626C65txt "double"
04602 C8000000000000 00i64 200
04F0F 0A 3F000000 4600 0000map leaf, size 10: @3F → @46
0594C 6E616D65txt "name"
05E3C 426F62txt "Bob"
0620F 0A 59000000 5E00 0000map leaf, size 10: @59 → @5E
06C07 0E 00A00000 4F00 0000 62000000map branch, size 14, depth 0 (root), slots 13, 15: @4F → @62
07A6C 646F75626C65txt "double"
08102 B4000000000000 00i64 180
08A0F 0A 7A000000 8100 0000map leaf, size 10: @7A → @81
0944C 6E616D65txt "name"
0992C 4379txt "Cy"
09C0F 0A 94000000 9900 0000map leaf, size 10: @94 → @99
0A607 0E 00A00000 8A00 0000 9C000000map branch, size 14, depth 0 (root), slots 13, 15: @8A → @9C
0B46C 646F75626C65txt "double"
0BB02 8C000000000000 00i64 140
0C40F 0A B4000000 BB00 0000map leaf, size 10: @B4 → @BB
0CE4C 6E616D65txt "name"
0D33C 44616Etxt "Dan"
0D70F 0A CE000000 D300 0000map leaf, size 10: @CE → @D3
0E107 0E 00A00000 C400 0000 D7000000map branch, size 14, depth 0 (root), slots 13, 15: @C4 → @D7
0EF6C 646F75626C65txt "double"
0F602 A0000000000000 00i64 160
0FF0F 0A EF000000 F600 0000map leaf, size 10: @EF → @F6
1094C 6E616D65txt "name"
10E3C 457665txt "Eve"
1120F 0A 09010000 0E01 0000map leaf, size 10: @109 → @10E
11C07 0E 00A00000 FF00 0000 12010000map branch, size 14, depth 0 (root), slots 13, 15: @FF → @112
12A0E 1D 00 1F00 050000 00 31000000 6C0000 00 A6000000 E10000 00 1C010000array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @31 → @6C → @A6 → @E1 → @11C

A schema clause keeps the entities whose current document matches a stored schema. It names the schema by its path below definitions/schemas, without a suffix. A stored schema supplies the validation rule.

Exact indexes

An exact index maps the values of a field to the entities that hold them. Stardust makes one for each field that a stored query or mutation compares with a value:

  • a fact clause with a constant or parameter value, such as [?e dept sales] or [?e dept ?dept] when ?dept is a parameter.
  • a =, <, <=, > or >= predicate on the value of a fact clause, such as [?e age ?age] with [>= ?age 18].
  • an in predicate on the value of a fact clause, with a list of constants or a list parameter. For example, [?e name ?name] with [in ?name ?names] reads only the listed values.

The database maintains exact indexes for fields that stored definitions or ad-hoc native runs compare. A scan gives the same rows while an index is not yet active. The engine tracks index status internally.

Parameters

A ?variable that no clause binds becomes a required input when only a predicate, a derivation or a having entry reads it. Stardust rejects an evaluation without a value for it.

TRON244 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A0E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
172C 3F65txt "?e"
1A6C 73616C617279txt "salary"
214C 3F73616Ctxt "?sal"
260E 15 00 0700 030000 00 17000000 1A0000 00 21000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @17 → @1A → @21
3B2C 3F65txt "?e"
3E4C 6E616D65txt "name"
435C 3F6E616D65txt "?name"
490E 15 00 0700 030000 00 3B000000 3E0000 00 43000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3B → @3E → @43
5E1C 3Etxt ">"
604C 3F73616Ctxt "?sal"
656C 3F666C6F6F72txt "?floor"
6C0E 15 00 0700 030000 00 5E000000 600000 00 65000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @5E → @60 → @65
810E 15 00 0700 030000 00 26000000 490000 00 6C000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @26 → @49 → @6C
965C 3F6E616D65txt "?name"
9C0E 0D 00 0100 010000 00 96000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @96
A95C 7768657265txt "where"
AF0F 0A A9000000 8100 0000map leaf, size 10: @A9 → @81
B94C 66696E64txt "find"
BE0F 0A B9000000 0A00 0000map leaf, size 10: @B9 → @A
C87C 6F726465724279txt "orderBy"
D00F 0A C8000000 9C00 0000map leaf, size 10: @C8 → @9C
DA07 12 2A000000 AF00 0000 BE000000 D000 0000map branch, size 18, depth 0 (root), slots 1, 3, 5: @AF → @BE → @D0

Error

Missing_Parameter

The caller gives the value with the query. With floor set to 95:

TRON67 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 6E616D65txt "name"
093C 416461txt "Ada"
0D0F 0A 04000000 0900 0000map leaf, size 10: @4 → @9
174C 6E616D65txt "name"
1C3C 426F62txt "Bob"
200F 0A 17000000 1C00 0000map leaf, size 10: @17 → @1C
2A0E 11 00 0300 020000 00 0D000000 200000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @D → @20

A parameters block gives a default instead, which makes the input optional. A declaration key uses ?name, like every other binding.

TRON305 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0046C 3F666C6F6F72txt "?floor"
00B02 5F000000000000 00i64 95
0140F 0A 04000000 0B00 0000map leaf, size 10: @4 → @B
01E5C 3F6E616D65txt "?name"
0240E 0D 00 0100 010000 00 1E000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @1E
0312C 3F65txt "?e"
0346C 73616C617279txt "salary"
03B4C 3F73616Ctxt "?sal"
0400E 15 00 0700 030000 00 31000000 340000 00 3B000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @31 → @34 → @3B
0552C 3F65txt "?e"
0584C 6E616D65txt "name"
05D5C 3F6E616D65txt "?name"
0630E 15 00 0700 030000 00 55000000 580000 00 5D000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @55 → @58 → @5D
0781C 3Etxt ">"
07A4C 3F73616Ctxt "?sal"
07F6C 3F666C6F6F72txt "?floor"
0860E 15 00 0700 030000 00 78000000 7A0000 00 7F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @78 → @7A → @7F
09B0E 15 00 0700 030000 00 40000000 630000 00 86000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @40 → @63 → @86
0B05C 3F6E616D65txt "?name"
0B60E 0D 00 0100 010000 00 B0000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @B0
0C35C 7768657265txt "where"
0C90F 0A C3000000 9B00 0000map leaf, size 10: @C3 → @9B
0D34C 66696E64txt "find"
0D80F 0A D3000000 2400 0000map leaf, size 10: @D3 → @24
0E2AC 706172616D6574 657273txt "parameters"
0ED0F 0A E2000000 1400 0000map leaf, size 10: @E2 → @14
0F77C 6F726465724279txt "orderBy"
0FF0F 0A F7000000 B600 0000map leaf, size 10: @F7 → @B6
10907 0E 20080000 ED00 0000 FF000000map branch, size 14, depth 1, slots 5, 11: @ED → @FF
11707 12 2A000000 C900 0000 D8000000 0901 0000map branch, size 18, depth 0 (root), slots 1, 3, 5: @C9 → @D8 → @109
TRON67 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 6E616D65txt "name"
093C 416461txt "Ada"
0D0F 0A 04000000 0900 0000map leaf, size 10: @4 → @9
174C 6E616D65txt "name"
1C3C 426F62txt "Bob"
200F 0A 17000000 1C00 0000map leaf, size 10: @17 → @1C
2A0E 11 00 0300 020000 00 0D000000 200000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @D → @20

A variable that no clause binds, and that no predicate reads, is an error. In this query, no clause binds ?dept:

TRON134 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A5C 3F64657074txt "?dept"
100E 11 00 0300 020000 00 04000000 0A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A
212C 3F65txt "?e"
244C 6E616D65txt "name"
295C 3F6E616D65txt "?name"
2F0E 15 00 0700 030000 00 21000000 240000 00 29000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @21 → @24 → @29
440E 0D 00 0100 010000 00 2F000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @2F
515C 7768657265txt "where"
570F 0A 51000000 4400 0000map leaf, size 10: @51 → @44
614C 66696E64txt "find"
660F 0A 61000000 1000 0000map leaf, size 10: @61 → @10
7007 0E 0A000000 5700 0000 66000000map branch, size 14, depth 0 (root), slots 1, 3: @57 → @66

Error

Unbound_Variable

Result mode

A query gives one object for each row, keyed by the find columns. With resultMode positional, it gives one list for each row, in find order.

TRON250 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A4C 3F73616Ctxt "?sal"
0F0E 11 00 0300 020000 00 04000000 0A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A
202C 3F65txt "?e"
236C 73616C617279txt "salary"
2A4C 3F73616Ctxt "?sal"
2F0E 15 00 0700 030000 00 20000000 230000 00 2A000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @20 → @23 → @2A
442C 3F65txt "?e"
474C 6E616D65txt "name"
4C5C 3F6E616D65txt "?name"
520E 15 00 0700 030000 00 44000000 470000 00 4C000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @44 → @47 → @4C
670E 11 00 0300 020000 00 2F000000 520000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @2F → @52
785C 3F6E616D65txt "?name"
7E0E 0D 00 0100 010000 00 78000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @78
8B5C 7768657265txt "where"
910F 0A 8B000000 6700 0000map leaf, size 10: @8B → @67
9B4C 66696E64txt "find"
A00F 0A 9B000000 0F00 0000map leaf, size 10: @9B → @F
AA7C 6F726465724279txt "orderBy"
B20F 0A AA000000 7E00 0000map leaf, size 10: @AA → @7E
BCAC 726573756C744D 6F6465txt "resultMode"
C7AC 706F736974696F 6E616Ctxt "positional"
D20F 0A BC000000 C700 0000map leaf, size 10: @BC → @C7
DC07 16 2A020000 9100 0000 A0000000 B200 0000 D2000000map branch, size 22, depth 0 (root), slots 1, 3, 5, 9: @91 → @A0 → @B2 → @D2
TRON190 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
043C 416461txt "Ada"
0802 78000000000000 00i64 120
110E 11 00 0300 020000 00 04000000 080000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @8
223C 426F62txt "Bob"
2602 64000000000000 00i64 100
2F0E 11 00 0300 020000 00 22000000 260000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @22 → @26
402C 4379txt "Cy"
4302 5A000000000000 00i64 90
4C0E 11 00 0300 020000 00 40000000 430000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @40 → @43
5D3C 44616Etxt "Dan"
6102 46000000000000 00i64 70
6A0E 11 00 0300 020000 00 5D000000 610000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @5D → @61
7B3C 457665txt "Eve"
7F02 50000000000000 00i64 80
880E 11 00 0300 020000 00 7B000000 7F0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @7B → @7F
990E 1D 00 1F00 050000 00 11000000 2F0000 00 4C000000 6A0000 00 88000000array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @11 → @2F → @4C → @6A → @88

Project shapes each row into a document instead. Grouping adds aggregates and window functions.

Run it

database query · query run.