Skip to content

Commit d19dca0

Browse files
committed
fix LTREE sizing guidance and comparison example
1 parent 674ea68 commit d19dca0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/current/v25.4/ltree.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SELECT 'Animals.Mammals.Carnivora'::LTREE;
2222
Animals.Mammals.Carnivora
2323
~~~
2424

25-
Each label in the path must contain only alphanumeric characters (`A`-`Z`, `a`-`z`, `0`-`9`), underscores (`_`), and hyphens (`-`).
25+
Each label in the path must contain only alphanumeric characters (`A`-`Z`, `a`-`z`, `0`-`9`), underscores (`_`), and hyphens (`-`). The maximum label length is 1,000 characters, and the maximum number of labels in a path is 65,535.
2626

2727
The following are valid `LTREE` values:
2828

@@ -33,7 +33,7 @@ The following are valid `LTREE` values:
3333

3434
## Size
3535

36-
The size of an `LTREE` value is variable and equals the total number of characters in all labels plus the dot separators. The maximum label length is 1,000 characters, and the maximum number of labels in a path is 65,535.
36+
The size of an `LTREE` value is variable and equals the total number of characters in all labels plus the dot separators. Cockroach Labs recommends keeping values below 64 kilobytes. Above that threshold, [write amplification]({% link {{ page.version.version }}/architecture/storage-layer.md %}#write-amplification) and other considerations may cause significant performance degradation.
3737

3838
## Operators
3939

@@ -126,20 +126,24 @@ INSERT INTO org_structure (id, path, name) VALUES
126126

127127
### Query `LTREE` with comparison operator
128128

129-
Find all entries named `Episode 1`:
129+
Find all entries that come before `Studio.ShowB` using lexicographic ordering. The `<` operator returns entries where the path is lexicographically less than `Studio.ShowB`:
130130

131131
{% include_cached copy-clipboard.html %}
132132
~~~ sql
133133
SELECT name, path FROM org_structure
134-
WHERE name = 'Episode 1';
134+
WHERE path < 'Studio.ShowB'
135+
ORDER BY path;
135136
~~~
136137

137138
~~~
138-
name | path
139-
------------+--------------------------------
140-
Episode 1 | Studio.ShowA.Season1.Episode1
141-
Episode 1 | Studio.ShowB.Season1.Episode1
142-
(2 rows)
139+
name | path
140+
--------------------+--------------------------------
141+
Production Studio | Studio
142+
Show A | Studio.ShowA
143+
Season 1 | Studio.ShowA.Season1
144+
Episode 1 | Studio.ShowA.Season1.Episode1
145+
Episode 2 | Studio.ShowA.Season1.Episode2
146+
(5 rows)
143147
~~~
144148

145149
### Query `LTREE` with containment operator

0 commit comments

Comments
 (0)