@@ -37,17 +37,55 @@ might be a time gap between the start time and the earliest timestamp. This
3737doesn't affect your usual interactions with your $HYPERTABLE, but might affect
3838the number of chunks you see when inspecting it.
3939
40+ ## Best practices for scaling and partitioning
41+
42+ Best practices for maintaining a high performance when scaling include:
43+
44+ - Limit the number of $HYPERTABLEs in your $SERVICE_SHORT; having tens of thousands of $HYPERTABLEs is not recommended.
45+ - Choose a strategic chunk size.
46+
47+ Chunk size affects insert and query performance. You want a chunk small enough
48+ to fit into memory so you can insert and query recent data without
49+ reading from disk. However, having too many small and sparsely filled chunks can
50+ affect query planning time and compression. The more chunks in the system, the slower that process becomes, even more so
51+ when all those chunks are part of a single hypertable.
52+
53+ <ChunkInterval />
54+
55+ For a detailed analysis of how to optimize your chunk sizes, see the
56+ [ blog post on chunk time intervals] [ blog-chunk-time ] . To learn how
57+ to view and set your chunk time intervals, see
58+ [ Optimize $HYPERTABLE chunk intervals] [ change-chunk-intervals ] .
59+
60+ ## $HYPERTABLE_CAP indexes
61+
62+ By default, indexes are automatically created when you create a $HYPERTABLE. The default index is on time, descending.
63+ You can prevent index creation by setting the ` create_default_indexes ` option to ` false ` .
64+
65+ $HYPERTABLE_CAPs have some restrictions on unique constraints and indexes. If you
66+ want a unique index on a $HYPERTABLE, it must include all the partitioning
67+ columns for the table. To learn more, see
68+ [ Enforce constraints with unique indexes on $HYPERTABLEs] [ hypertables-and-unique-indexes ] .
69+
70+ You can prevent index creation by setting the ` create_default_indexes ` option to ` false ` .
71+
4072## Partition by dimension
4173
4274Partitioning on time is the most common use case for $HYPERTABLE, but it may not be enough for your needs. For example,
4375you may need to scan for the latest readings that match a certain condition without locking a critical $HYPERTABLE.
44- Best practice to optimize ingest and query performance is to add a partitioning dimension on a non-time column such as
45- location or device UUID, and specify a number of partitions.
4676
47- You add a partitioning dimension at the same time as you create the hypertable, when the table is empty. The good news
48- is that although you select the number of partitions at creation time, as your data grows you can change the number of
49- partitions later and improve query performance. Changing the number of partitions only affects chunks created after the
50- change, not existing chunks. To set the number of partitions for a partitioning dimension, call ` set_number_partitions ` .
77+ <Highlight type =" note " >
78+
79+ The use case for a partitioning dimension is a multi-tenant setup. You isolate the tenants using the ` tenant_id ` space
80+ partition. However, you must perform extensive testing to ensure this works as expected, and there is a strong risk of
81+ partition explosion.
82+
83+ </Highlight >
84+
85+ You add a partitioning dimension at the same time as you create the hypertable, when the table is empty. The good news
86+ is that although you select the number of partitions at creation time, as your data grows you can change the number of
87+ partitions later and improve query performance. Changing the number of partitions only affects chunks created after the
88+ change, not existing chunks. To set the number of partitions for a partitioning dimension, call ` set_number_partitions ` .
5189For example:
5290
5391<Procedure >
@@ -82,44 +120,6 @@ For example:
82120
83121</Procedure >
84122
85- ## Best practices for scaling and partitioning
86-
87- Best practices for maintaining a high performance when scaling include:
88-
89- - Limit the number of $HYPERTABLEs in your $SERVICE_SHORT; having tens of thousands of $HYPERTABLEs is not recommended.
90- - Choose a strategic chunk size.
91-
92- Chunk size affects insert and query performance. You want a chunk small enough
93- to fit into memory so you can insert and query recent data without
94- reading from disk. However, having too many small and sparsely filled chunks can
95- affect query planning time and compression. The more chunks in the system, the slower that process becomes, even more so
96- when all those chunks are part of a single hypertable.
97-
98- <ChunkInterval />
99-
100- For a detailed analysis of how to optimize your chunk sizes, see the
101- [ blog post on chunk time intervals] [ blog-chunk-time ] . To learn how
102- to view and set your chunk time intervals, see
103- [ Optimize $HYPERTABLE chunk intervals] [ change-chunk-intervals ] .
104-
105- ## $HYPERTABLE_CAP indexes
106-
107- By default, indexes are automatically created when you create a $HYPERTABLE. The default index is on time, descending.
108- You can prevent index creation by setting the ` create_default_indexes ` option to ` false ` .
109-
110- $HYPERTABLE_CAPs have some restrictions on unique constraints and indexes. If you
111- want a unique index on a $HYPERTABLE, it must include all the partitioning
112- columns for the table. To learn more, see
113- [ Enforce constraints with unique indexes on $HYPERTABLEs] [ hypertables-and-unique-indexes ] .
114-
115- You can prevent index creation by setting the ` create_default_indexes ` option to ` false ` .
116-
117- This section shows you:
118-
119- * [ Optimize time-series data in hypertables] [ create-hypertables ]
120- * [ Improve hypertable and query performance] [ change-chunk-intervals ]
121- * [ Enforce constraints with unique indexes] [ hypertables-and-unique-indexes ]
122- * [ Troubleshooting] [ troubleshooting ]
123123
124124[ about-distributed-hypertables ] : /self-hosted/:currentVersion:/distributed-hypertables/about-distributed-hypertables/
125125[ best-practices-space ] : #best-practices-for-space-partitioning
0 commit comments