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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 6C 73616C617279 | txt "salary" |
| 00B | 02 78000000000000 00 | i64 120 |
| 014 | 0F 0A 04000000 0B00 0000 | map leaf, size 10: @4 → @B |
| 01E | 3C 616765 | txt "age" |
| 022 | 02 24000000000000 00 | i64 36 |
| 02B | 0F 0A 1E000000 2200 0000 | map leaf, size 10: @1E → @22 |
| 035 | 4C 726F6C65 | txt "role" |
| 03A | 8C 656E67696E6565 72 | txt "engineer" |
| 043 | 0F 0A 35000000 3A00 0000 | map leaf, size 10: @35 → @3A |
| 04D | 4C 64657074 | txt "dept" |
| 052 | 3C 656E67 | txt "eng" |
| 056 | 0F 0A 4D000000 5200 0000 | map leaf, size 10: @4D → @52 |
| 060 | 07 0E 20080000 4300 0000 56000000 | map branch, size 14, depth 1, slots 5, 11: @43 → @56 |
| 06E | 4C 6E616D65 | txt "name" |
| 073 | 3C 416461 | txt "Ada" |
| 077 | 0F 0A 6E000000 7300 0000 | map leaf, size 10: @6E → @73 |
| 081 | 07 16 10910000 1400 0000 2B000000 6000 0000 77000000 | map branch, size 22, depth 0 (root), slots 4, 8, 12, 15: @14 → @2B → @60 → @77 |
| 097 | 5C 236C696E6B | txt "#link" |
| 09D | 5C 235F616461 | txt "#_ada" |
| 0A3 | 0F 0A 97000000 9D00 0000 | map leaf, size 10: @97 → @9D |
| 0AD | 6C 73616C617279 | txt "salary" |
| 0B4 | 02 64000000000000 00 | i64 100 |
| 0BD | 0F 0A AD000000 B400 0000 | map leaf, size 10: @AD → @B4 |
| 0C7 | 3C 616765 | txt "age" |
| 0CB | 02 29000000000000 00 | i64 41 |
| 0D4 | 0F 0A C7000000 CB00 0000 | map leaf, size 10: @C7 → @CB |
| 0DE | 6C 6D656E746F72 | txt "mentor" |
| 0E5 | 0F 0A DE000000 A300 0000 | map leaf, size 10: @DE → @A3 |
| 0EF | 4C 726F6C65 | txt "role" |
| 0F4 | 8C 656E67696E6565 72 | txt "engineer" |
| 0FD | 0F 0A EF000000 F400 0000 | map leaf, size 10: @EF → @F4 |
Show all 87 nodes
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 107 | 4C 64657074 | txt "dept" |
| 10C | 3C 656E67 | txt "eng" |
| 110 | 0F 0A 07010000 0C01 0000 | map leaf, size 10: @107 → @10C |
| 11A | 07 0E 20080000 FD00 0000 10010000 | map branch, size 14, depth 1, slots 5, 11: @FD → @110 |
| 128 | 4C 6E616D65 | txt "name" |
| 12D | 3C 426F62 | txt "Bob" |
| 131 | 0F 0A 28010000 2D01 0000 | map leaf, size 10: @128 → @12D |
| 13B | 07 1A 10990000 BD00 0000 D4000000 E500 0000 1A010000 3101 0000 | map branch, size 26, depth 0 (root), slots 4, 8, 11, 12, 15: @BD → @D4 → @E5 → @11A → @131 |
| 155 | 6C 73616C617279 | txt "salary" |
| 15C | 02 5A000000000000 00 | i64 90 |
| 165 | 0F 0A 55010000 5C01 0000 | map leaf, size 10: @155 → @15C |
| 16F | 3C 616765 | txt "age" |
| 173 | 02 1D000000000000 00 | i64 29 |
| 17C | 0F 0A 6F010000 7301 0000 | map leaf, size 10: @16F → @173 |
| 186 | 4C 726F6C65 | txt "role" |
| 18B | 8C 64657369676E65 72 | txt "designer" |
| 194 | 0F 0A 86010000 8B01 0000 | map leaf, size 10: @186 → @18B |
| 19E | 4C 64657074 | txt "dept" |
| 1A3 | 5C 73616C6573 | txt "sales" |
| 1A9 | 0F 0A 9E010000 A301 0000 | map leaf, size 10: @19E → @1A3 |
| 1B3 | 07 0E 20080000 9401 0000 A9010000 | map branch, size 14, depth 1, slots 5, 11: @194 → @1A9 |
| 1C1 | 4C 6E616D65 | txt "name" |
| 1C6 | 2C 4379 | txt "Cy" |
| 1C9 | 0F 0A C1010000 C601 0000 | map leaf, size 10: @1C1 → @1C6 |
| 1D3 | 07 16 10910000 6501 0000 7C010000 B301 0000 C9010000 | map branch, size 22, depth 0 (root), slots 4, 8, 12, 15: @165 → @17C → @1B3 → @1C9 |
| 1E9 | 6C 73616C617279 | txt "salary" |
| 1F0 | 02 46000000000000 00 | i64 70 |
| 1F9 | 0F 0A E9010000 F001 0000 | map leaf, size 10: @1E9 → @1F0 |
| 203 | 4C 64657074 | txt "dept" |
| 208 | 5C 73616C6573 | txt "sales" |
| 20E | 0F 0A 03020000 0802 0000 | map leaf, size 10: @203 → @208 |
| 218 | 4C 6E616D65 | txt "name" |
| 21D | 3C 44616E | txt "Dan" |
| 221 | 0F 0A 18020000 1D02 0000 | map leaf, size 10: @218 → @21D |
| 22B | 07 12 10900000 F901 0000 0E020000 2102 0000 | map branch, size 18, depth 0 (root), slots 4, 12, 15: @1F9 → @20E → @221 |
| 23D | 6C 73616C617279 | txt "salary" |
| 244 | 02 50000000000000 00 | i64 80 |
| 24D | 0F 0A 3D020000 4402 0000 | map leaf, size 10: @23D → @244 |
| 257 | 4C 64657074 | txt "dept" |
| 25C | 3C 6F7073 | txt "ops" |
| 260 | 0F 0A 57020000 5C02 0000 | map leaf, size 10: @257 → @25C |
| 26A | 4C 6E616D65 | txt "name" |
| 26F | 3C 457665 | txt "Eve" |
| 273 | 0F 0A 6A020000 6F02 0000 | map leaf, size 10: @26A → @26F |
| 27D | 07 12 10900000 4D02 0000 60020000 7302 0000 | map branch, size 18, depth 0 (root), slots 4, 12, 15: @24D → @260 → @273 |
| 28F | 5C 235F64616E | txt "#_dan" |
| 295 | 0F 0A 8F020000 2B02 0000 | map leaf, size 10: @28F → @22B |
| 29F | 4C 235F6379 | txt "#_cy" |
| 2A4 | 0F 0A 9F020000 D301 0000 | map leaf, size 10: @29F → @1D3 |
| 2AE | 5C 235F626F62 | txt "#_bob" |
| 2B4 | 0F 0A AE020000 3B01 0000 | map leaf, size 10: @2AE → @13B |
| 2BE | 5C 235F657665 | txt "#_eve" |
| 2C4 | 0F 0A BE020000 7D02 0000 | map leaf, size 10: @2BE → @27D |
| 2CE | 5C 235F616461 | txt "#_ada" |
| 2D4 | 0F 0A CE020000 8100 0000 | map leaf, size 10: @2CE → @81 |
| 2DE | 07 1A 82310000 9502 0000 A4020000 B402 0000 C4020000 D402 0000 | map branch, size 26, depth 0 (root), slots 1, 7, 8, 12, 13: @295 → @2A4 → @2B4 → @2C4 → @2D4 |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 2F8 | DE020000 00000000 | root → @2DE; previous: none |
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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 3F6E616D65 | txt "?name" |
| 0A | 4C 3F73616C | txt "?sal" |
| 0F | 0E 11 00 0300 020000 00 04000000 0A0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A |
| 20 | 2C 3F65 | txt "?e" |
| 23 | 4C 64657074 | txt "dept" |
| 28 | 5C 3F64657074 | txt "?dept" |
| 2E | 0E 15 00 0700 030000 00 20000000 230000 00 28000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @20 → @23 → @28 |
| 43 | 2C 3F65 | txt "?e" |
| 46 | 6C 73616C617279 | txt "salary" |
| 4D | 4C 3F73616C | txt "?sal" |
| 52 | 0E 15 00 0700 030000 00 43000000 460000 00 4D000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @43 → @46 → @4D |
| 67 | 2C 3F65 | txt "?e" |
| 6A | 4C 6E616D65 | txt "name" |
| 6F | 5C 3F6E616D65 | txt "?name" |
| 75 | 0E 15 00 0700 030000 00 67000000 6A0000 00 6F000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @67 → @6A → @6F |
| 8A | 0E 15 00 0700 030000 00 2E000000 520000 00 75000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @2E → @52 → @75 |
| 9F | 5C 3F6E616D65 | txt "?name" |
| A5 | 0E 0D 00 0100 010000 00 9F000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @9F |
| B2 | 5C 7768657265 | txt "where" |
| B8 | 0F 0A B2000000 8A00 0000 | map leaf, size 10: @B2 → @8A |
| C2 | 4C 66696E64 | txt "find" |
| C7 | 0F 0A C2000000 0F00 0000 | map leaf, size 10: @C2 → @F |
| D1 | 7C 6F726465724279 | txt "orderBy" |
| D9 | 0F 0A D1000000 A500 0000 | map leaf, size 10: @D1 → @A5 |
| E3 | 07 12 2A000000 B800 0000 C7000000 D900 0000 | map branch, size 18, depth 0 (root), slots 1, 3, 5: @B8 → @C7 → @D9 |
| F5 | E3000000 00000000 | root → @E3; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 3C 73616C | txt "sal" |
| 008 | 02 78000000000000 00 | i64 120 |
| 011 | 0F 0A 04000000 0800 0000 | map leaf, size 10: @4 → @8 |
| 01B | 4C 6E616D65 | txt "name" |
| 020 | 3C 416461 | txt "Ada" |
| 024 | 0F 0A 1B000000 2000 0000 | map leaf, size 10: @1B → @20 |
| 02E | 07 0E 80800000 1100 0000 24000000 | map branch, size 14, depth 0 (root), slots 7, 15: @11 → @24 |
| 03C | 3C 73616C | txt "sal" |
| 040 | 02 64000000000000 00 | i64 100 |
| 049 | 0F 0A 3C000000 4000 0000 | map leaf, size 10: @3C → @40 |
| 053 | 4C 6E616D65 | txt "name" |
| 058 | 3C 426F62 | txt "Bob" |
| 05C | 0F 0A 53000000 5800 0000 | map leaf, size 10: @53 → @58 |
| 066 | 07 0E 80800000 4900 0000 5C000000 | map branch, size 14, depth 0 (root), slots 7, 15: @49 → @5C |
| 074 | 3C 73616C | txt "sal" |
| 078 | 02 5A000000000000 00 | i64 90 |
| 081 | 0F 0A 74000000 7800 0000 | map leaf, size 10: @74 → @78 |
| 08B | 4C 6E616D65 | txt "name" |
| 090 | 2C 4379 | txt "Cy" |
| 093 | 0F 0A 8B000000 9000 0000 | map leaf, size 10: @8B → @90 |
| 09D | 07 0E 80800000 8100 0000 93000000 | map branch, size 14, depth 0 (root), slots 7, 15: @81 → @93 |
| 0AB | 3C 73616C | txt "sal" |
| 0AF | 02 46000000000000 00 | i64 70 |
| 0B8 | 0F 0A AB000000 AF00 0000 | map leaf, size 10: @AB → @AF |
| 0C2 | 4C 6E616D65 | txt "name" |
| 0C7 | 3C 44616E | txt "Dan" |
| 0CB | 0F 0A C2000000 C700 0000 | map leaf, size 10: @C2 → @C7 |
| 0D5 | 07 0E 80800000 B800 0000 CB000000 | map branch, size 14, depth 0 (root), slots 7, 15: @B8 → @CB |
| 0E3 | 3C 73616C | txt "sal" |
| 0E7 | 02 50000000000000 00 | i64 80 |
| 0F0 | 0F 0A E3000000 E700 0000 | map leaf, size 10: @E3 → @E7 |
| 0FA | 4C 6E616D65 | txt "name" |
| 0FF | 3C 457665 | txt "Eve" |
| 103 | 0F 0A FA000000 FF00 0000 | map leaf, size 10: @FA → @FF |
| 10D | 07 0E 80800000 F000 0000 03010000 | map branch, size 14, depth 0 (root), slots 7, 15: @F0 → @103 |
| 11B | 0E 1D 00 1F00 050000 00 2E000000 660000 00 9D000000 D50000 00 0D010000 | array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @2E → @66 → @9D → @D5 → @10D |
| 138 | 1B010000 00000000 | root → @11B; previous: none |
Clauses
A where clause has one of these forms.
| Kind | Shape | Purpose |
|---|---|---|
| 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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 3F6B6579 | txt "?key" |
| 09 | 7C 3F617274697374 | txt "?artist" |
| 11 | 0E 11 00 0300 020000 00 04000000 090000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @9 |
| 22 | 6C 6D656D626572 | txt "member" |
| 29 | 6C 3F747261636B | txt "?track" |
| 30 | 7C 61727469737473 | txt "artists" |
| 38 | 4C 3F6B6579 | txt "?key" |
| 3D | 7C 3F617274697374 | txt "?artist" |
| 45 | 0E 1D 00 1F00 050000 00 22000000 290000 00 30000000 380000 00 3D000000 | array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @22 → @29 → @30 → @38 → @3D |
| 62 | 0E 0D 00 0100 010000 00 45000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @45 |
| 6F | 5C 7768657265 | txt "where" |
| 75 | 0F 0A 6F000000 6200 0000 | map leaf, size 10: @6F → @62 |
| 7F | 4C 66696E64 | txt "find" |
| 84 | 0F 0A 7F000000 1100 0000 | map leaf, size 10: @7F → @11 |
| 8E | 07 0E 0A000000 7500 0000 84000000 | map branch, size 14, depth 0 (root), slots 1, 3: @75 → @84 |
| 9C | 8E000000 00000000 | root → @8E; previous: none |
For example, this field has one member. Its name is a MusicBrainz GID. Its value
is a link to artist entity 8306.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 236C696E6B | txt "#link" |
| 0A | 02 72200000000000 00 | i64 8306 |
| 13 | 0F 0A 04000000 0A00 0000 | map leaf, size 10: @4 → @A |
| 1D | 14 20 616631653736 6630363238363463 6434623439383961 3732613864663764 6531 | txt "af1e76f062864cd4b4989a72…" |
| 3F | 0F 0A 1D000000 1300 0000 | map leaf, size 10: @1D → @13 |
| 49 | 7C 61727469737473 | txt "artists" |
| 51 | 0F 0A 49000000 3F00 0000 | map leaf, size 10: @49 → @3F |
| 5B | 51000000 00000000 | root → @51; previous: none |
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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 6C 3F7469746C65 | txt "?title" |
| 00B | 0E 0D 00 0100 010000 00 04000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 |
| 018 | 7C 3F617274697374 | txt "?artist" |
| 020 | 4C 6E616D65 | txt "name" |
| 025 | BC 4A6F686E204C65 6E6E6F6E | txt "John Lennon" |
| 031 | 0E 15 00 0700 030000 00 18000000 200000 00 25000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @18 → @20 → @25 |
| 046 | 6C 6D656D626572 | txt "member" |
| 04D | 6C 3F747261636B | txt "?track" |
| 054 | 7C 61727469737473 | txt "artists" |
| 05C | 1C 5F | txt "_" |
| 05E | 7C 3F617274697374 | txt "?artist" |
| 066 | 0E 1D 00 1F00 050000 00 46000000 4D0000 00 54000000 5C0000 00 5E000000 | array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @46 → @4D → @54 → @5C → @5E |
| 083 | 6C 3F747261636B | txt "?track" |
| 08A | 5C 747261636B | txt "track" |
| 090 | 1C 5F | txt "_" |
| 092 | 0E 15 00 0700 030000 00 83000000 8A0000 00 90000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @83 → @8A → @90 |
| 0A7 | 6C 3F747261636B | txt "?track" |
| 0AE | 4C 6E616D65 | txt "name" |
| 0B3 | 6C 3F7469746C65 | txt "?title" |
| 0BA | 0E 15 00 0700 030000 00 A7000000 AE0000 00 B3000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @A7 → @AE → @B3 |
| 0CF | 0E 19 00 0F00 040000 00 31000000 660000 00 92000000 BA0000 00 | array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @31 → @66 → @92 → @BA |
| 0E8 | 5C 7768657265 | txt "where" |
| 0EE | 0F 0A E8000000 CF00 0000 | map leaf, size 10: @E8 → @CF |
| 0F8 | 4C 66696E64 | txt "find" |
| 0FD | 0F 0A F8000000 0B00 0000 | map leaf, size 10: @F8 → @B |
| 107 | 07 0E 0A000000 EE00 0000 FD000000 | map branch, size 14, depth 0 (root), slots 1, 3: @EE → @FD |
| 115 | 07010000 00000000 | root → @107; previous: none |
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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 3F6E616D65 | txt "?name" |
| 0A | 0E 0D 00 0100 010000 00 04000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 |
| 17 | 2C 3F65 | txt "?e" |
| 1A | 4C 6E616D65 | txt "name" |
| 1F | 5C 3F6E616D65 | txt "?name" |
| 25 | 0E 15 00 0700 030000 00 17000000 1A0000 00 1F000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @17 → @1A → @1F |
| 3A | 2C 3F65 | txt "?e" |
| 3D | 4C 64657074 | txt "dept" |
| 42 | 3C 656E67 | txt "eng" |
| 46 | 0E 15 00 0700 030000 00 3A000000 3D0000 00 42000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3A → @3D → @42 |
| 5B | 3C 6E6F74 | txt "not" |
| 5F | 0E 11 00 0300 020000 00 5B000000 460000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @5B → @46 |
| 70 | 0E 11 00 0300 020000 00 25000000 5F0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @25 → @5F |
| 81 | 5C 3F6E616D65 | txt "?name" |
| 87 | 0E 0D 00 0100 010000 00 81000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @81 |
| 94 | 5C 7768657265 | txt "where" |
| 9A | 0F 0A 94000000 7000 0000 | map leaf, size 10: @94 → @70 |
| A4 | 4C 66696E64 | txt "find" |
| A9 | 0F 0A A4000000 0A00 0000 | map leaf, size 10: @A4 → @A |
| B3 | 7C 6F726465724279 | txt "orderBy" |
| BB | 0F 0A B3000000 8700 0000 | map leaf, size 10: @B3 → @87 |
| C5 | 07 12 2A000000 9A00 0000 A9000000 BB00 0000 | map branch, size 18, depth 0 (root), slots 1, 3, 5: @9A → @A9 → @BB |
| D7 | C5000000 00000000 | root → @C5; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 6E616D65 | txt "name" |
| 09 | 2C 4379 | txt "Cy" |
| 0C | 0F 0A 04000000 0900 0000 | map leaf, size 10: @4 → @9 |
| 16 | 4C 6E616D65 | txt "name" |
| 1B | 3C 44616E | txt "Dan" |
| 1F | 0F 0A 16000000 1B00 0000 | map leaf, size 10: @16 → @1B |
| 29 | 4C 6E616D65 | txt "name" |
| 2E | 3C 457665 | txt "Eve" |
| 32 | 0F 0A 29000000 2E00 0000 | map leaf, size 10: @29 → @2E |
| 3C | 0E 15 00 0700 030000 00 0C000000 1F0000 00 32000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @C → @1F → @32 |
| 51 | 3C000000 00000000 | root → @3C; previous: none |
A predicate keeps each solution that its expression accepts.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 3F6E616D65 | txt "?name" |
| 0A | 0E 0D 00 0100 010000 00 04000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 |
| 17 | 2C 3F65 | txt "?e" |
| 1A | 6C 73616C617279 | txt "salary" |
| 21 | 4C 3F73616C | txt "?sal" |
| 26 | 0E 15 00 0700 030000 00 17000000 1A0000 00 21000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @17 → @1A → @21 |
| 3B | 2C 3F65 | txt "?e" |
| 3E | 4C 6E616D65 | txt "name" |
| 43 | 5C 3F6E616D65 | txt "?name" |
| 49 | 0E 15 00 0700 030000 00 3B000000 3E0000 00 43000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3B → @3E → @43 |
| 5E | 1C 3E | txt ">" |
| 60 | 4C 3F73616C | txt "?sal" |
| 65 | 02 55000000000000 00 | i64 85 |
| 6E | 0E 15 00 0700 030000 00 5E000000 600000 00 65000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @5E → @60 → @65 |
| 83 | 0E 15 00 0700 030000 00 26000000 490000 00 6E000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @26 → @49 → @6E |
| 98 | 5C 3F6E616D65 | txt "?name" |
| 9E | 0E 0D 00 0100 010000 00 98000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @98 |
| AB | 5C 7768657265 | txt "where" |
| B1 | 0F 0A AB000000 8300 0000 | map leaf, size 10: @AB → @83 |
| BB | 4C 66696E64 | txt "find" |
| C0 | 0F 0A BB000000 0A00 0000 | map leaf, size 10: @BB → @A |
| CA | 7C 6F726465724279 | txt "orderBy" |
| D2 | 0F 0A CA000000 9E00 0000 | map leaf, size 10: @CA → @9E |
| DC | 07 12 2A000000 B100 0000 C0000000 D200 0000 | map branch, size 18, depth 0 (root), slots 1, 3, 5: @B1 → @C0 → @D2 |
| EE | DC000000 00000000 | root → @DC; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 6E616D65 | txt "name" |
| 09 | 3C 416461 | txt "Ada" |
| 0D | 0F 0A 04000000 0900 0000 | map leaf, size 10: @4 → @9 |
| 17 | 4C 6E616D65 | txt "name" |
| 1C | 3C 426F62 | txt "Bob" |
| 20 | 0F 0A 17000000 1C00 0000 | map leaf, size 10: @17 → @1C |
| 2A | 4C 6E616D65 | txt "name" |
| 2F | 2C 4379 | txt "Cy" |
| 32 | 0F 0A 2A000000 2F00 0000 | map leaf, size 10: @2A → @2F |
| 3C | 0E 15 00 0700 030000 00 0D000000 200000 00 32000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @D → @20 → @32 |
| 51 | 3C000000 00000000 | root → @3C; previous: none |
A derivation calculates a value and binds it to a new variable. The expression comes first, and the new variable follows it.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 5C 3F6E616D65 | txt "?name" |
| 00A | 7C 3F646F75626C65 | txt "?double" |
| 012 | 0E 11 00 0300 020000 00 04000000 0A0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A |
| 023 | 2C 3F65 | txt "?e" |
| 026 | 6C 73616C617279 | txt "salary" |
| 02D | 4C 3F73616C | txt "?sal" |
| 032 | 0E 15 00 0700 030000 00 23000000 260000 00 2D000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @23 → @26 → @2D |
| 047 | 2C 3F65 | txt "?e" |
| 04A | 4C 6E616D65 | txt "name" |
| 04F | 5C 3F6E616D65 | txt "?name" |
| 055 | 0E 15 00 0700 030000 00 47000000 4A0000 00 4F000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @47 → @4A → @4F |
| 06A | 1C 2A | txt "*" |
| 06C | 4C 3F73616C | txt "?sal" |
| 071 | 02 02000000000000 00 | i64 2 |
| 07A | 0E 15 00 0700 030000 00 6A000000 6C0000 00 71000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @6A → @6C → @71 |
| 08F | 7C 3F646F75626C65 | txt "?double" |
| 097 | 0E 11 00 0300 020000 00 7A000000 8F0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @7A → @8F |
| 0A8 | 0E 15 00 0700 030000 00 32000000 550000 00 97000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @32 → @55 → @97 |
| 0BD | 5C 3F6E616D65 | txt "?name" |
| 0C3 | 0E 0D 00 0100 010000 00 BD000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @BD |
| 0D0 | 5C 7768657265 | txt "where" |
| 0D6 | 0F 0A D0000000 A800 0000 | map leaf, size 10: @D0 → @A8 |
| 0E0 | 4C 66696E64 | txt "find" |
| 0E5 | 0F 0A E0000000 1200 0000 | map leaf, size 10: @E0 → @12 |
| 0EF | 7C 6F726465724279 | txt "orderBy" |
| 0F7 | 0F 0A EF000000 C300 0000 | map leaf, size 10: @EF → @C3 |
| 101 | 07 12 2A000000 D600 0000 E5000000 F700 0000 | map branch, size 18, depth 0 (root), slots 1, 3, 5: @D6 → @E5 → @F7 |
| 113 | 01010000 00000000 | root → @101; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 6C 646F75626C65 | txt "double" |
| 00B | 02 F0000000000000 00 | i64 240 |
| 014 | 0F 0A 04000000 0B00 0000 | map leaf, size 10: @4 → @B |
| 01E | 4C 6E616D65 | txt "name" |
| 023 | 3C 416461 | txt "Ada" |
| 027 | 0F 0A 1E000000 2300 0000 | map leaf, size 10: @1E → @23 |
| 031 | 07 0E 00A00000 1400 0000 27000000 | map branch, size 14, depth 0 (root), slots 13, 15: @14 → @27 |
| 03F | 6C 646F75626C65 | txt "double" |
| 046 | 02 C8000000000000 00 | i64 200 |
| 04F | 0F 0A 3F000000 4600 0000 | map leaf, size 10: @3F → @46 |
| 059 | 4C 6E616D65 | txt "name" |
| 05E | 3C 426F62 | txt "Bob" |
| 062 | 0F 0A 59000000 5E00 0000 | map leaf, size 10: @59 → @5E |
| 06C | 07 0E 00A00000 4F00 0000 62000000 | map branch, size 14, depth 0 (root), slots 13, 15: @4F → @62 |
| 07A | 6C 646F75626C65 | txt "double" |
| 081 | 02 B4000000000000 00 | i64 180 |
| 08A | 0F 0A 7A000000 8100 0000 | map leaf, size 10: @7A → @81 |
| 094 | 4C 6E616D65 | txt "name" |
| 099 | 2C 4379 | txt "Cy" |
| 09C | 0F 0A 94000000 9900 0000 | map leaf, size 10: @94 → @99 |
| 0A6 | 07 0E 00A00000 8A00 0000 9C000000 | map branch, size 14, depth 0 (root), slots 13, 15: @8A → @9C |
| 0B4 | 6C 646F75626C65 | txt "double" |
| 0BB | 02 8C000000000000 00 | i64 140 |
| 0C4 | 0F 0A B4000000 BB00 0000 | map leaf, size 10: @B4 → @BB |
| 0CE | 4C 6E616D65 | txt "name" |
| 0D3 | 3C 44616E | txt "Dan" |
| 0D7 | 0F 0A CE000000 D300 0000 | map leaf, size 10: @CE → @D3 |
| 0E1 | 07 0E 00A00000 C400 0000 D7000000 | map branch, size 14, depth 0 (root), slots 13, 15: @C4 → @D7 |
| 0EF | 6C 646F75626C65 | txt "double" |
| 0F6 | 02 A0000000000000 00 | i64 160 |
| 0FF | 0F 0A EF000000 F600 0000 | map leaf, size 10: @EF → @F6 |
| 109 | 4C 6E616D65 | txt "name" |
| 10E | 3C 457665 | txt "Eve" |
| 112 | 0F 0A 09010000 0E01 0000 | map leaf, size 10: @109 → @10E |
| 11C | 07 0E 00A00000 FF00 0000 12010000 | map branch, size 14, depth 0 (root), slots 13, 15: @FF → @112 |
| 12A | 0E 1D 00 1F00 050000 00 31000000 6C0000 00 A6000000 E10000 00 1C010000 | array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @31 → @6C → @A6 → @E1 → @11C |
| 147 | 2A010000 00000000 | root → @12A; previous: none |
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?deptis a parameter. - a
=,<,<=,>or>=predicate on the value of a fact clause, such as[?e age ?age]with[>= ?age 18]. - an
inpredicate 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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 3F6E616D65 | txt "?name" |
| 0A | 0E 0D 00 0100 010000 00 04000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4 |
| 17 | 2C 3F65 | txt "?e" |
| 1A | 6C 73616C617279 | txt "salary" |
| 21 | 4C 3F73616C | txt "?sal" |
| 26 | 0E 15 00 0700 030000 00 17000000 1A0000 00 21000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @17 → @1A → @21 |
| 3B | 2C 3F65 | txt "?e" |
| 3E | 4C 6E616D65 | txt "name" |
| 43 | 5C 3F6E616D65 | txt "?name" |
| 49 | 0E 15 00 0700 030000 00 3B000000 3E0000 00 43000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3B → @3E → @43 |
| 5E | 1C 3E | txt ">" |
| 60 | 4C 3F73616C | txt "?sal" |
| 65 | 6C 3F666C6F6F72 | txt "?floor" |
| 6C | 0E 15 00 0700 030000 00 5E000000 600000 00 65000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @5E → @60 → @65 |
| 81 | 0E 15 00 0700 030000 00 26000000 490000 00 6C000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @26 → @49 → @6C |
| 96 | 5C 3F6E616D65 | txt "?name" |
| 9C | 0E 0D 00 0100 010000 00 96000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @96 |
| A9 | 5C 7768657265 | txt "where" |
| AF | 0F 0A A9000000 8100 0000 | map leaf, size 10: @A9 → @81 |
| B9 | 4C 66696E64 | txt "find" |
| BE | 0F 0A B9000000 0A00 0000 | map leaf, size 10: @B9 → @A |
| C8 | 7C 6F726465724279 | txt "orderBy" |
| D0 | 0F 0A C8000000 9C00 0000 | map leaf, size 10: @C8 → @9C |
| DA | 07 12 2A000000 AF00 0000 BE000000 D000 0000 | map branch, size 18, depth 0 (root), slots 1, 3, 5: @AF → @BE → @D0 |
| EC | DA000000 00000000 | root → @DA; previous: none |
Error
Missing_Parameter
The caller gives the value with the query. With floor set to 95:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 6E616D65 | txt "name" |
| 09 | 3C 416461 | txt "Ada" |
| 0D | 0F 0A 04000000 0900 0000 | map leaf, size 10: @4 → @9 |
| 17 | 4C 6E616D65 | txt "name" |
| 1C | 3C 426F62 | txt "Bob" |
| 20 | 0F 0A 17000000 1C00 0000 | map leaf, size 10: @17 → @1C |
| 2A | 0E 11 00 0300 020000 00 0D000000 200000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @D → @20 |
| 3B | 2A000000 00000000 | root → @2A; previous: none |
A parameters block gives a default instead, which makes the input optional.
A declaration key uses ?name, like every other binding.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 6C 3F666C6F6F72 | txt "?floor" |
| 00B | 02 5F000000000000 00 | i64 95 |
| 014 | 0F 0A 04000000 0B00 0000 | map leaf, size 10: @4 → @B |
| 01E | 5C 3F6E616D65 | txt "?name" |
| 024 | 0E 0D 00 0100 010000 00 1E000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @1E |
| 031 | 2C 3F65 | txt "?e" |
| 034 | 6C 73616C617279 | txt "salary" |
| 03B | 4C 3F73616C | txt "?sal" |
| 040 | 0E 15 00 0700 030000 00 31000000 340000 00 3B000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @31 → @34 → @3B |
| 055 | 2C 3F65 | txt "?e" |
| 058 | 4C 6E616D65 | txt "name" |
| 05D | 5C 3F6E616D65 | txt "?name" |
| 063 | 0E 15 00 0700 030000 00 55000000 580000 00 5D000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @55 → @58 → @5D |
| 078 | 1C 3E | txt ">" |
| 07A | 4C 3F73616C | txt "?sal" |
| 07F | 6C 3F666C6F6F72 | txt "?floor" |
| 086 | 0E 15 00 0700 030000 00 78000000 7A0000 00 7F000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @78 → @7A → @7F |
| 09B | 0E 15 00 0700 030000 00 40000000 630000 00 86000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @40 → @63 → @86 |
| 0B0 | 5C 3F6E616D65 | txt "?name" |
| 0B6 | 0E 0D 00 0100 010000 00 B0000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @B0 |
| 0C3 | 5C 7768657265 | txt "where" |
| 0C9 | 0F 0A C3000000 9B00 0000 | map leaf, size 10: @C3 → @9B |
| 0D3 | 4C 66696E64 | txt "find" |
| 0D8 | 0F 0A D3000000 2400 0000 | map leaf, size 10: @D3 → @24 |
| 0E2 | AC 706172616D6574 657273 | txt "parameters" |
| 0ED | 0F 0A E2000000 1400 0000 | map leaf, size 10: @E2 → @14 |
| 0F7 | 7C 6F726465724279 | txt "orderBy" |
| 0FF | 0F 0A F7000000 B600 0000 | map leaf, size 10: @F7 → @B6 |
| 109 | 07 0E 20080000 ED00 0000 FF000000 | map branch, size 14, depth 1, slots 5, 11: @ED → @FF |
| 117 | 07 12 2A000000 C900 0000 D8000000 0901 0000 | map branch, size 18, depth 0 (root), slots 1, 3, 5: @C9 → @D8 → @109 |
| 129 | 17010000 00000000 | root → @117; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 4C 6E616D65 | txt "name" |
| 09 | 3C 416461 | txt "Ada" |
| 0D | 0F 0A 04000000 0900 0000 | map leaf, size 10: @4 → @9 |
| 17 | 4C 6E616D65 | txt "name" |
| 1C | 3C 426F62 | txt "Bob" |
| 20 | 0F 0A 17000000 1C00 0000 | map leaf, size 10: @17 → @1C |
| 2A | 0E 11 00 0300 020000 00 0D000000 200000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @D → @20 |
| 3B | 2A000000 00000000 | root → @2A; previous: none |
A variable that no clause binds, and that no predicate reads, is an error. In
this query, no clause binds ?dept:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 3F6E616D65 | txt "?name" |
| 0A | 5C 3F64657074 | txt "?dept" |
| 10 | 0E 11 00 0300 020000 00 04000000 0A0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A |
| 21 | 2C 3F65 | txt "?e" |
| 24 | 4C 6E616D65 | txt "name" |
| 29 | 5C 3F6E616D65 | txt "?name" |
| 2F | 0E 15 00 0700 030000 00 21000000 240000 00 29000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @21 → @24 → @29 |
| 44 | 0E 0D 00 0100 010000 00 2F000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @2F |
| 51 | 5C 7768657265 | txt "where" |
| 57 | 0F 0A 51000000 4400 0000 | map leaf, size 10: @51 → @44 |
| 61 | 4C 66696E64 | txt "find" |
| 66 | 0F 0A 61000000 1000 0000 | map leaf, size 10: @61 → @10 |
| 70 | 07 0E 0A000000 5700 0000 66000000 | map branch, size 14, depth 0 (root), slots 1, 3: @57 → @66 |
| 7E | 70000000 00000000 | root → @70; previous: none |
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.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 5C 3F6E616D65 | txt "?name" |
| 0A | 4C 3F73616C | txt "?sal" |
| 0F | 0E 11 00 0300 020000 00 04000000 0A0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A |
| 20 | 2C 3F65 | txt "?e" |
| 23 | 6C 73616C617279 | txt "salary" |
| 2A | 4C 3F73616C | txt "?sal" |
| 2F | 0E 15 00 0700 030000 00 20000000 230000 00 2A000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @20 → @23 → @2A |
| 44 | 2C 3F65 | txt "?e" |
| 47 | 4C 6E616D65 | txt "name" |
| 4C | 5C 3F6E616D65 | txt "?name" |
| 52 | 0E 15 00 0700 030000 00 44000000 470000 00 4C000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @44 → @47 → @4C |
| 67 | 0E 11 00 0300 020000 00 2F000000 520000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @2F → @52 |
| 78 | 5C 3F6E616D65 | txt "?name" |
| 7E | 0E 0D 00 0100 010000 00 78000000 | array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @78 |
| 8B | 5C 7768657265 | txt "where" |
| 91 | 0F 0A 8B000000 6700 0000 | map leaf, size 10: @8B → @67 |
| 9B | 4C 66696E64 | txt "find" |
| A0 | 0F 0A 9B000000 0F00 0000 | map leaf, size 10: @9B → @F |
| AA | 7C 6F726465724279 | txt "orderBy" |
| B2 | 0F 0A AA000000 7E00 0000 | map leaf, size 10: @AA → @7E |
| BC | AC 726573756C744D 6F6465 | txt "resultMode" |
| C7 | AC 706F736974696F 6E616C | txt "positional" |
| D2 | 0F 0A BC000000 C700 0000 | map leaf, size 10: @BC → @C7 |
| DC | 07 16 2A020000 9100 0000 A0000000 B200 0000 D2000000 | map branch, size 22, depth 0 (root), slots 1, 3, 5, 9: @91 → @A0 → @B2 → @D2 |
| F2 | DC000000 00000000 | root → @DC; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 3C 416461 | txt "Ada" |
| 08 | 02 78000000000000 00 | i64 120 |
| 11 | 0E 11 00 0300 020000 00 04000000 080000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @8 |
| 22 | 3C 426F62 | txt "Bob" |
| 26 | 02 64000000000000 00 | i64 100 |
| 2F | 0E 11 00 0300 020000 00 22000000 260000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @22 → @26 |
| 40 | 2C 4379 | txt "Cy" |
| 43 | 02 5A000000000000 00 | i64 90 |
| 4C | 0E 11 00 0300 020000 00 40000000 430000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @40 → @43 |
| 5D | 3C 44616E | txt "Dan" |
| 61 | 02 46000000000000 00 | i64 70 |
| 6A | 0E 11 00 0300 020000 00 5D000000 610000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @5D → @61 |
| 7B | 3C 457665 | txt "Eve" |
| 7F | 02 50000000000000 00 | i64 80 |
| 88 | 0E 11 00 0300 020000 00 7B000000 7F0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @7B → @7F |
| 99 | 0E 1D 00 1F00 050000 00 11000000 2F0000 00 4C000000 6A0000 00 88000000 | array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @11 → @2F → @4C → @6A → @88 |
| B6 | 99000000 00000000 | root → @99; previous: none |
Project shapes each row into a document instead. Grouping adds aggregates and window functions.