You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tech-notes/jsonb_forward_indexing.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,10 +44,18 @@ The following rules were kept in mind while designing this form of encoding, as
44
44
5. Objects with an equal number of key value pairs are compared in the order:
45
45
`key1`, `value1`, `key2`, `value2`, ….
46
46
47
+
**NOTE:** There is one exception to these rules, which is neither documented by
48
+
Postgres, nor mentioned in the source code: empty arrays are the minimum JSON
49
+
value. As far as we can tell, this is a Postgres bug that has existed for some
50
+
time. We've decided to replicate this behavior to remain consistent with
51
+
Postgres. We've filed a [Postgres bug report](https://www.postgresql.org/message-id/17873-826fdc8bbcace4f1%40postgresql.org)
52
+
to track the issue.
53
+
47
54
In order to satisfy property 1 at all times, tags are defined in an increasing order of bytes.
48
55
These tags will also have to be defined in a way where the tag representing an object is a large byte representation
49
56
for a hexadecimal value (such as 0xff) and the subsequent objects have a value 1 less than the previous one,
50
-
where the ordering is described in point 1 above.
57
+
where the ordering is described in point 1 above. There is a special tag for empty JSON arrays
58
+
in order to handle the special case of empty arrays being ordered before all other JSON values.
51
59
52
60
Additionally, tags representing terminators will also be defined. There will be two terminators, one for the ascending designation and the other for the descending one, and will be required to denote the end of a key encoding of the following JSON values: Objects, Arrays, Number and Strings. JSON Boolean and JSON Null are not required to have the terminator since they do not have variable length encoding due to the presence of a single tag (as explained later in this document).
0 commit comments