@@ -140,61 +140,70 @@ seconds or longer as files and partitions increase.
140
140
Use the following filters to optimize your system table queries and reduce the impact on your
141
141
cluster's performance.
142
142
143
+ In your queries, replace the following:
144
+
145
+ - {{% code-placeholder-key %}}` TABLE_NAME ` {{% /code-placeholder-key %}}: the table to retrieve partitions for
146
+ - {{% code-placeholder-key %}}` PARTITION_ID ` {{% /code-placeholder-key %}}: a [ partition ID] ( #retrieve-a-partition-id ) (int64)
147
+ - {{% code-placeholder-key %}}` PARTITION_KEY ` {{% /code-placeholder-key %}}: a [ partition key] ( /influxdb/cloud-dedicated/admin/custom-partitions/#partition-keys )
148
+ derived from the table's partition template.
149
+ The default format is ` %Y-%m-%d ` (for example, ` 2024-01-01 ` ).
150
+
143
151
##### Filter by table name
144
152
145
153
When querying the ` system.tables ` , ` system.partitions ` , or ` system.compactor ` tables, use the
146
154
` WHERE ` clause to filter by ` table_name ` .
147
155
156
+ {{% code-placeholders "TABLE_NAME" %}}
148
157
``` sql
149
158
SELECT * FROM system .partitions WHERE table_name = ' TABLE_NAME'
150
159
```
160
+ {{% /code-placeholders%}}
151
161
152
162
##### Filter by partition key
153
163
154
164
When querying the ` system.partitions ` or ` system.compactor ` tables, use the ` WHERE ` clause to
155
- filter by ` partition_key ` .
165
+ filter by ` partition_key ` .
156
166
167
+ {{% code-placeholders "PARTITION_KEY" %}}
157
168
``` sql
158
169
SELECT * FROM system .partitions WHERE partition_key = ' PARTITION_KEY'
159
170
```
171
+ {{% /code-placeholders %}}
160
172
161
173
To further improve performance, use ` AND ` to pair ` partition_key ` with ` table_name ` --for example:
162
-
174
+
175
+ {{% code-placeholders "TABLE_NAME|PARTITION_KEY" %}}
163
176
``` sql
164
177
SELECT *
165
178
FROM system .partitions
166
179
WHERE
167
180
table_name = ' TABLE_NAME'
168
181
AND partition_key = ' PARTITION_KEY' ;
169
182
```
170
-
171
- Replace the following:
172
-
173
- - ` TABLE_NAME ` : the table to retrieve partitions for
174
- - ` PARTITION_KEY ` : a [ partition key] ( /influxdb/cloud-dedicated/admin/custom-partitions/#partition-keys )
175
- derived from the table's partition template.
176
- The default format is ` %Y-%m-%d ` (for example, ` 2024-01-01 ` ).
183
+ {{% /code-placeholders %}}
177
184
178
185
##### Filter by partition ID
179
186
180
187
When querying the ` system.partitions ` or ` system.compactor ` table, use the ` WHERE ` clause to
181
188
filter by ` partition_id ` .
182
189
190
+ {{% code-placeholders "PARTITION_ID" %}}
183
191
``` sql
184
192
SELECT * FROM system .partitions WHERE partition_id = PARTITION_ID
185
193
```
194
+ {{% /code-placeholders %}}
186
195
187
196
For the most optimized approach, use ` AND ` to pair ` partition_id ` with ` table_name ` --for example:
188
197
198
+ {{% code-placeholders "TABLE_NAME|PARTITION_ID" %}}
189
199
``` sql
190
200
SELECT *
191
201
FROM system .partitions
192
202
WHERE
193
203
table_name = ' TABLE_NAME'
194
204
AND partition_id = PARTITION_ID;
195
205
```
196
-
197
- - ` PARTITION_ID ` : a [ partition ID] ( #retrieve-a-partition-id ) (int64)
206
+ {{% /code-placeholders %}}
198
207
199
208
Although you don't need to pair ` partition_id ` with ` table_name ` (because a partition ID is unique within a cluster),
200
209
it's the most optimized approach, _ especially when you have many tables in a database_ .
@@ -203,6 +212,7 @@ it's the most optimized approach, _especially when you have many tables in a dat
203
212
204
213
To retrieve a partition ID, query ` system.partitions ` for a ` table_name ` and ` partition_key ` pair--for example:
205
214
215
+ {{% code-placeholders "TABLE_NAME|PARTITION_KEY" %}}
206
216
``` sql
207
217
SELECT
208
218
table_name,
@@ -213,6 +223,7 @@ WHERE
213
223
table_name = ' TABLE_NAME'
214
224
AND partition_key = ' PARTITION_KEY' ;
215
225
```
226
+ {{% /code-placeholders %}}
216
227
217
228
The result contains the ` partition_id ` :
218
229
0 commit comments