diff --git a/content/influxdb/cloud-dedicated/admin/custom-partitions/best-practices.md b/content/influxdb/cloud-dedicated/admin/custom-partitions/best-practices.md index c558808d3..ac4e9d7f6 100644 --- a/content/influxdb/cloud-dedicated/admin/custom-partitions/best-practices.md +++ b/content/influxdb/cloud-dedicated/admin/custom-partitions/best-practices.md @@ -47,12 +47,9 @@ As you plan your partitioning strategy, keep in mind that data can be having to retrieve and read many partitions from the object store, which hurts query performance. -- Avoid using partition time intervals that are **less than one day**. - - The partition time interval should be balanced with the actual amount of data - written during each interval. If a single interval doesn't contain a lot of data, +- Balance the partition time interval with the actual amount of data written + during each interval. If a single interval doesn't contain a lot of data, it is better to partition by larger time intervals. - - Don't partition by tags that you typically don't use in your query workload. - Don't partition by distinct values of high-cardinality tags. Instead, [use tag buckets](#use-tag-buckets-for-high-cardinality-tags) to diff --git a/content/influxdb/cloud-dedicated/admin/custom-partitions/define-custom-partitions.md b/content/influxdb/cloud-dedicated/admin/custom-partitions/define-custom-partitions.md index 46129a41b..66246a7d7 100644 --- a/content/influxdb/cloud-dedicated/admin/custom-partitions/define-custom-partitions.md +++ b/content/influxdb/cloud-dedicated/admin/custom-partitions/define-custom-partitions.md @@ -28,13 +28,13 @@ table. - [Create a table with a custom partition template](#create-a-table-with-a-custom-partition-template) - [Example partition templates](#example-partition-templates) -{{% note %}} +{{% warn %}} #### Partition templates can only be applied on create You can only apply a partition template when creating a database or table. You can't update a partition template on an existing resource. -{{% /note %}} +{{% /warn %}} Use the following command flags to identify [partition template parts](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#tag-part-templates): @@ -69,7 +69,7 @@ Otherwise, InfluxDB omits time from the partition template and won't compact par The following example creates a new `example-db` database and applies a partition template that partitions by distinct values of two tags (`room` and `sensor-type`), -bucketed values of the `customerID` tag, and by week using the time format `%Y wk:%W`: +bucketed values of the `customerID` tag, and by day using the time format `%Y-%m-%d`: @@ -79,7 +79,7 @@ influxctl database create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,500 \ - --template-timeformat '%Y wk:%W' \ + --template-timeformat '%Y-%m-%d' \ example-db ``` @@ -150,22 +150,21 @@ prod,line=A,station=weld1 temp=81.9,qty=36i 1704067200000000000 ##### Partitioning by distinct tag values -| Description | Tag parts | Time part | Resulting partition key | +| Description | Tag parts | Time part | Resulting partition key | | :---------------------- | :---------------- | :--------- | :----------------------- | | By day (default) | | `%Y-%m-%d` | 2024-01-01 | -| By day (non-default) | | `%d %b %Y` | 01 Jan 2024 | -| By week | | `%Y wk:%W` | 2024 wk:01 | | By month | | `%Y-%m` | 2024-01 | -| Single tag, by day | `line` | `%F` | A \| 2024-01-01 | -| Single tag, by week | `line` | `%Y wk:%W` | A \| 2024 wk:01 | +| By year | | `%Y` | 2024 | +| Single tag, by day | `line` | `%Y-%m-%d` | A \| 2024-01-01 | | Single tag, by month | `line` | `%Y-%m` | A \| 2024-01 | -| Multiple tags, by day | `line`, `station` | `%F` | A \| weld1 \| 2024-01-01 | -| Multiple tags, by week | `line`, `station` | `%Y wk:%W` | A \| weld1 \| 2024 wk:01 | +| Single tag, by year | `line` | `%Y` | A \| 2024 | +| Multiple tags, by day | `line`, `station` | `%Y-%m-%d` | A \| weld1 \| 2024-01-01 | | Multiple tags, by month | `line`, `station` | `%Y-%m` | A \| weld1 \| 2024-01 | +| Multiple tags, by year | `line`, `station` | `%Y` | A \| weld1 \| 2024 | ##### Partition by tag buckets -| Description | Tag part | Tag bucket part | Time part | Resulting partition key | -| :--------------------------------- | :------- | :-------------- | :--------- | :---------------------- | -| Distinct tag, tag buckets, by day | `line` | `station,100` | `%F` | A \| 3 \| 2024-01-01 | -| Distinct tag, tag buckets, by week | `line` | `station,500` | `%Y wk:%W` | A \| 303 \| 2024 wk:01 | +| Description | Tag part | Tag bucket part | Time part | Resulting partition key | +| :---------------------------------- | :------- | :-------------- | :--------- | :---------------------- | +| Distinct tag, tag buckets, by day | `line` | `station,100` | `%Y-%m-%d` | A \| 3 \| 2024-01-01 | +| Distinct tag, tag buckets, by month | `line` | `station,500` | `%Y-%m` | A \| 303 \| 2024-01 | diff --git a/content/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates.md b/content/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates.md index d024539bc..22c812b28 100644 --- a/content/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates.md +++ b/content/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates.md @@ -39,11 +39,6 @@ and only 1 time part. - [Tag part templates](#tag-part-templates) - [Tag bucket part templates](#tag-bucket-part-templates) - [Time part templates](#time-part-templates) - - [Date specifiers](#date-specifiers) - - [Time specifiers](#time-specifiers) - - [Time zone specifiers](#time-zone-specifiers) - - [Date and time specifiers](#date-and-time-specifiers) - - [Special specifiers](#special-specifiers) ## Restrictions @@ -109,175 +104,16 @@ unknown number of distinct values. ## Time part templates -Time part templates use [Rust strftime date and time formatting syntax](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) +Time part templates use a limited subset of the +[Rust strftime date and time formatting syntax](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) to specify time format in partition keys. -The smallest unit of time included in the time part template is the interval -used to partition data. - -{{% warn %}} -#### Avoid partitioning by less than one day - -We do not recommend using time intervals less than one day to partition data. -This can result in [over-partitioned data](/influxdb/cloud-dedicated/admin/custom-partitions/best-practices/#avoid-over-partitioning) -and may hurt query performance. -{{% /warn %}} - -- [Date specifiers](#date-specifiers) -- [Time specifiers](#time-specifiers) -- [Time zone specifiers](#time-zone-specifiers) -- [Date and time specifiers](#date-and-time-specifiers) -- [Special specifiers](#special-specifiers) - -{{% note %}} -The following is adapted from the -[Rust strftime source code](https://docs.rs/chrono/latest/src/chrono/format/strftime.rs.html). -{{% /note %}} +InfluxDB uses the smallest unit of time included in the time part template as +the partition interval. ### Date specifiers -| Variable | Example | Description | -| :------: | :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `%Y` | `2001` | The full proleptic Gregorian year, zero-padded to 4 digits. chrono supports years from -262144 to 262143. Note: years before 1 BCE or after 9999 CE, require an initial sign (+/-). | -| `%C` | `20` | The proleptic Gregorian year divided by 100, zero-padded to 2 digits. [^1] | -| `%y` | `01` | The proleptic Gregorian year modulo 100, zero-padded to 2 digits. [^1] | -| `%m` | `07` | Month number (01--12), zero-padded to 2 digits. | -| `%b` | `Jul` | Abbreviated month name. Always 3 letters. | -| `%B` | `July` | Full month name. Also accepts corresponding abbreviation in parsing. | -| `%h` | `Jul` | Same as `%b`. | -| `%d` | `08` | Day number (01--31), zero-padded to 2 digits. | -| `%e` | ` 8` | Same as `%d` but space-padded. Same as `%_d`. | -| `%a` | `Sun` | Abbreviated weekday name. Always 3 letters. | -| `%A` | `Sunday` | Full weekday name. Also accepts corresponding abbreviation in parsing. | -| `%w` | `0` | Sunday = 0, Monday = 1, ..., Saturday = 6. | -| `%u` | `7` | Monday = 1, Tuesday = 2, ..., Sunday = 7. (ISO 8601) | -| `%U` | `28` | Week number starting with Sunday (00--53), zero-padded to 2 digits. [^2] | -| `%W` | `27` | Same as `%U`, but week 1 starts with the first Monday in that year instead. | -| `%G` | `2001` | Same as `%Y` but uses the year number in ISO 8601 week date. [^3] | -| `%g` | `01` | Same as `%y` but uses the year number in ISO 8601 week date. [^3] | -| `%V` | `27` | Same as `%U` but uses the week number in ISO 8601 week date (01--53). [^3] | -| `%j` | `189` | Day of the year (001--366), zero-padded to 3 digits. | -| `%D` | `07/08/01` | Month-day-year format. Same as `%m/%d/%y`. | -| `%x` | `07/08/01` | Locale's date representation (e.g., 12/31/99). | -| `%F` | `2001-07-08` | Year-month-day format (ISO 8601). Same as `%Y-%m-%d`. | -| `%v` | ` 8-Jul-2001` | Day-month-year format. Same as `%e-%b-%Y`. | - -### Time specifiers - -| Variable | Example | Description | -| :------: | :--------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | -| `%H` | `00` | Hour number (00--23), zero-padded to 2 digits. | -| `%k` | ` 0` | Same as `%H` but space-padded. Same as `%_H`. | -| `%I` | `12` | Hour number in 12-hour clocks (01--12), zero-padded to 2 digits. | -| `%l` | `12` | Same as `%I` but space-padded. Same as `%_I`. | -| `%P` | `am` | `am` or `pm` in 12-hour clocks. | -| `%p` | `AM` | `AM` or `PM` in 12-hour clocks. | -| `%M` | `34` | Minute number (00--59), zero-padded to 2 digits. | -| `%S` | `60` | Second number (00--60), zero-padded to 2 digits. [^4] | -| `%f` | `26490000` | Number of nanoseconds since last whole second. [^7] | -| `%.f` | `.026490` | Decimal fraction of a second. Consumes the leading dot. [^7] | -| `%.3f` | `.026` | Decimal fraction of a second with a fixed length of 3. | -| `%.6f` | `.026490` | Decimal fraction of a second with a fixed length of 6. | -| `%.9f` | `.026490000` | Decimal fraction of a second with a fixed length of 9. | -| `%3f` | `026` | Decimal fraction of a second like `%.3f` but without the leading dot. | -| `%6f` | `026490` | Decimal fraction of a second like `%.6f` but without the leading dot. | -| `%9f` | `026490000` | Decimal fraction of a second like `%.9f` but without the leading dot. | -| `%R` | `00:34` | Hour-minute format. Same as `%H:%M`. | -| `%T` | `00:34:60` | Hour-minute-second format. Same as `%H:%M:%S`. | -| `%X` | `00:34:60` | Locale's time representation (e.g., 23:13:48). | -| `%r` | `12:34:60 AM` | Locale's 12 hour clock time. (e.g., 11:11:04 PM). Falls back to `%X` if the locale does not have a 12 hour clock format. | - -### Time zone specifiers - -| Variable | Example | Description | -| :------: | :--------------------------------- | :----------------------------------------------------------------------------------------------------------------- | -| `%Z` | `ACST` | Local time zone name. Skips all non-whitespace characters during parsing. Identical to `%:z` when formatting. [^8] | -| `%z` | `+0930` | Offset from the local time to UTC (with UTC being `+0000`). | -| `%:z` | `+09:30` | Same as `%z` but with a colon. | -| `%::z` | `+09:30:00` | Offset from the local time to UTC with seconds. | -| `%:::z` | `+09` | Offset from the local time to UTC without minutes. | -| `%#z` | `+09` | *Parsing only:* Same as `%z` but allows minutes to be missing or present. | - -### Date and time specifiers - -| Variable | Example | Description | -| :------: | :--------------------------------- | :--------------------------------------------------------------------- | -| `%c` | `Sun Jul 8 00:34:60 2001` | Locale's date and time (e.g., Thu Mar 3 23:05:25 2005). | -| `%+` | `2001-07-08T00:34:60.026490+09:30` | ISO 8601 / RFC 3339 date & time format. [^5] | -| `%s` | `994518299` | UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. [^6] | - -### Special specifiers - -| Variable | Example | Description | -| :------: | :------ | :---------------------- | -| `%t` | | Literal tab (`\t`). | -| `%n` | | Literal newline (`\n`). | -| `%%` | | Literal percent sign. | - -It is possible to override the default padding behavior of numeric specifiers `%?`. -This is not allowed for other specifiers and results in the `BAD_FORMAT` error. - -Modifier | Description --------- | ----------- -`%-?` | Suppresses any padding including spaces and zeroes. (e.g. `%j` = `012`, `%-j` = `12`) -`%_?` | Uses spaces as a padding. (e.g. `%j` = `012`, `%_j` = ` 12`) -`%0?` | Uses zeroes as a padding. (e.g. `%e` = ` 9`, `%0e` = `09`) - -Notes: - -[^1]: `%C`, `%y`: - This is floor division, so 100 BCE (year number -99) will print `-1` and `99` respectively. -[^2]: `%U`: - Week 1 starts with the first Sunday in that year. - It is possible to have week 0 for days before the first Sunday. - -[^3]: `%G`, `%g`, `%V`: - Week 1 is the first week with at least 4 days in that year. - Week 0 does not exist, so this should be used with `%G` or `%g`. - -[^4]: `%S`: - It accounts for leap seconds, so `60` is possible. - -[^5]: `%+`: Same as `%Y-%m-%dT%H:%M:%S%.f%:z`, i.e. 0, 3, 6 or 9 fractional - digits for seconds and colons in the time zone offset. -
-
- This format also supports having a `Z` or `UTC` in place of `%:z`. They - are equivalent to `+00:00`. -
-
- Note that all `T`, `Z`, and `UTC` are parsed case-insensitively. -
-
- The typical `strftime` implementations have different (and locale-dependent) - formats for this specifier. While Chrono's format for `%+` is far more - stable, it is best to avoid this specifier if you want to control the exact - output. - -[^6]: `%s`: - This is not padded and can be negative. - For the purpose of Chrono, it only accounts for non-leap seconds - so it slightly differs from ISO C `strftime` behavior. - -[^7]: `%f`, `%.f`: -
- `%f` and `%.f` are notably different formatting specifiers.
- `%f` counts the number of nanoseconds since the last whole second, while `%.f` is a fraction of a - second.
- Example: 7μs is formatted as `7000` with `%f`, and formatted as `.000007` with `%.f`. - -[^8]: `%Z`: - Since `chrono` is not aware of timezones beyond their offsets, this specifier - **only prints the offset** when used for formatting. The timezone abbreviation - will NOT be printed. See [this issue](https://github.com/chronotope/chrono/issues/960) - for more information. -
-
- Offset will not be populated from the parsed data, nor will it be validated. - Timezone is completely ignored. Similar to the glibc `strptime` treatment of - this format code. -
-
- It is not possible to reliably convert from an abbreviation to an offset, - for example CDT can mean either Central Daylight Time (North America) or - China Daylight Time. -*/ \ No newline at end of file +| Variable | Example | Description | +| :------: | :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%Y` | `2001` | The full proleptic Gregorian year, zero-padded to 4 digits. chrono supports years from -262144 to 262143. Note: years before 1 BCE or after 9999 CE, require an initial sign (+/-). | +| `%m` | `07` | Month number (01--12), zero-padded to 2 digits. | +| `%d` | `08` | Day number (01--31), zero-padded to 2 digits. | diff --git a/content/influxdb/cloud-dedicated/admin/custom-partitions/view-partitions.md b/content/influxdb/cloud-dedicated/admin/custom-partitions/view-partitions.md new file mode 100644 index 000000000..38b667011 --- /dev/null +++ b/content/influxdb/cloud-dedicated/admin/custom-partitions/view-partitions.md @@ -0,0 +1,198 @@ +--- +title: View partition information +description: > + Query partition information from InfluxDB v3 system tables to view partition + templates and verify partitions are working as intended. +menu: + influxdb_cloud_dedicated: + name: View partitions + parent: Manage data partitioning +weight: 202 +list_code_example: | + ```sql + SELECT * FROM system.partitions WHERE table_name = 'example-table' + ``` +related: + - /influxdb/cloud-dedicated/admin/query-system-data/ +--- + +{{< product-name >}} stores partition information in InfluxDB v3 system tables. +Query partition information to view partition templates and verify partitions +are working as intended. + +- [Query partition information from system tables](#query-partition-information-from-system-tables) +- [Partition-related queries](#partition-related-queries) + +{{% warn %}} +#### Querying system tables may impact overall cluster performance + +Partition information is stored in InfluxDB v3 system tables. +Querying system tables may impact the overall write and query performance of +your {{< product-name omit=" Clustered" >}} cluster. + + + +#### System tables are subject to change + +System tables are not part of InfluxDB's stable API and may change with new releases. +The provided schema information and query examples are valid as of **August 22, 2024**. +If you detect a schema change or a non-functioning query example, please +[submit an issue](https://github.com/influxdata/docs-v2/issues/new/choose). + + + +{{% /warn %}} + +## Query partition information from system tables + +Use the [`influxctl query` command](/influxdb/cloud-dedicated/reference/cli/influxctl/query/) +and SQL to query partition-related information from InfluxDB system tables. + Provide the following: + +- **Enable system tables** with the `--enable-system-tables` command flag. +- **Database token**: A [database token](/influxdb/cloud-dedicated/admin/tokens/#database-tokens) + with read permissions on the specified database. Uses the `token` setting from + the [`influxctl` connection profile](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles) + or the `--token` command flag. +- **Database name**: The name of the database to query information about. + Uses the `database` setting from the + [`influxctl` connection profile](/influxdb/cloud-dedicated/reference/cli/influxctl/#configure-connection-profiles) + or the `--database` command flag. +- **SQL query**: The SQL query to execute. + Pass the query in one of the following ways: + + - a string on the command line + - a path to a file that contains the query + - a single dash (`-`) to read the query from stdin + +{{% code-placeholders "DATABASE_(TOKEN|NAME)|SQL_QUERY" %}} + +```bash +influxctl query \ + --enable-system-tables \ + --database DATABASE_NAME \ + --token DATABASE_TOKEN \ + "SQL_QUERY" +``` + +{{% /code-placeholders %}} + +Replace the following: + +- {{% code-placeholder-key %}}`DATABASE_TOKEN`{{% /code-placeholder-key %}}: + A database token with read access to the specified database +- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: + The name of the database to query information about. +- {{% code-placeholder-key %}}`SQL_QUERY`{{% /code-placeholder-key %}}: + The SQL query to execute. For examples, see + [System query examples](#system-query-examples). + +When prompted, enter `y` to acknowledge the potential impact querying system +tables may have on your cluster. + +## Partition-related queries + +Use the following queries to return information about partitions in your +{{< product-name omit=" Clustered" >}} cluster. + +- [View partition templates of all tables](#view-partition-templates-of-all-tables) +- [View the partition template of a specific table](#view-the-partition-template-of-a-specific-table) +- [View all partitions for a table](#view-all-partitions-for-a-table) +- [View the number of partitions per table](#view-the-number-of-partitions-per-table) +- [View the number of partitions for a specific table](#view-the-number-of-partitions-for-a-specific-table) + +--- + +In the examples below, replace {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}} +with the name of the table you want to query information about. + +--- + +{{% code-placeholders "TABLE_NAME" %}} + +### View partition templates of all tables + +```sql +SELECT * FROM system.tables +``` + +#### Example results + +| table_name | partition_template | +| :--------- | :----------------------------------------------------------------------------------------- | +| weather | `{"parts":[{"timeFormat":"%Y-%m-%d"},{"bucket":{"tagName":"location","numBuckets":250}}]}` | +| home | `{"parts":[{"timeFormat":"%Y-%m-%d"},{"tagValue":"room"},{"tagValue":"sensor_id"}]}` | +| numbers | `{"parts":[{"timeFormat":"%Y"}]}` | + +{{% note %}} +If a table doesn't include a partition template in the output of this command, +the table uses the default (1 day) partition strategy and doesn't partition +by tags or tag buckets. +{{% /note %}} + +### View the partition template of a specific table + +```sql +SELECT * FROM system.tables WHERE table_name = 'TABLE_NAME' +``` + +#### Example results + +| table_name | partition_template | +| :--------- | :----------------------------------------------------------------------------------------- | +| weather | `{"parts":[{"timeFormat":"%Y-%m-%d"},{"bucket":{"tagName":"location","numBuckets":250}}]}` | + +### View all partitions for a table + +```sql +SELECT * FROM system.partitions WHERE table_name = 'TABLE_NAME' +``` + +### Example results + +| partition_id | table_name | partition_key | last_new_file_created_at | num_files | total_size_mb | +| -----------: | :--------- | :---------------- | -----------------------: | --------: | ------------: | +| 1362 | weather | 43 \| 2020-05-27 | 1683747418763813713 | 1 | 0 | +| 800 | weather | 234 \| 2021-08-02 | 1683747421899400796 | 1 | 0 | +| 630 | weather | 325 \| 2022-03-17 | 1683747417616689036 | 1 | 0 | +| 1401 | weather | 12 \| 2021-01-09 | 1683747417786122295 | 1 | 0 | +| 1012 | weather | 115 \| 2022-07-04 | 1683747417614219148 | 1 | 0 | + +### View the number of partitions per table + +```sql +SELECT + table_name, + COUNT(*) AS partition_count +FROM + system.partitions +GROUP BY + table_name +``` + +### Example results + +| table_name | partition_count | +| :--------- | --------------: | +| weather | 1096 | +| home | 24 | +| numbers | 1 | + +### View the number of partitions for a specific table + +```sql +SELECT + COUNT(*) AS partition_count +FROM + system.partitions +WHERE + table_name = 'TABLE_NAME' +``` + +### Example results + +| table_name | partition_count | +| :--------- | --------------: | +| weather | 1096 | + +{{% /code-placeholders %}} diff --git a/content/influxdb/cloud-dedicated/admin/databases/create.md b/content/influxdb/cloud-dedicated/admin/databases/create.md index a40c1bc15..7ca86519e 100644 --- a/content/influxdb/cloud-dedicated/admin/databases/create.md +++ b/content/influxdb/cloud-dedicated/admin/databases/create.md @@ -194,14 +194,6 @@ flags to define partition template parts used to generate partition keys for the For more information, see [Manage data partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/). -{{% note %}} - -#### Partition templates can only be applied on create - -You can only apply a partition template when creating a database. -You can't update a partition template on an existing database. -{{% /note %}} - {{% /tab-content %}} {{% tab-content %}} @@ -235,7 +227,7 @@ _This example uses [cURL](https://curl.se/) to send a Management HTTP API reques to use in the partition template. Limit is 7 total tags or tag buckets. - _Optional_: [InfluxDB tag buckets](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#tag-bucket-part-templates) to use in the partition template. Limit is 7 total tags or tag buckets. - - _Optional_: A [Rust strftime date and time string](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#time-part-templates) + - _Optional_: A supported [Rust strftime date and time string](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#time-part-templates) that specifies the time format in the partition template and determines the time interval to partition by. Default is `%Y-%m-%d`. - Database name _(see [Database naming restrictions](#database-naming-restrictions))_. @@ -341,21 +333,23 @@ format in the InfluxDB v3 storage engine. By default, data is partitioned by day but, depending on your schema and workload, customizing the partitioning strategy can improve query performance. -Use the [`partitionTemplate`](/influxdb/cloud-dedicated/api/management/#operation/CreateClusterDatabase) property to define an array of partition template parts used to generate partition keys for the database. +Use the [`partitionTemplate`](/influxdb/cloud-dedicated/api/management/#operation/CreateClusterDatabase) +property to define an array of partition template parts used to generate +partition keys for the database. For more information, see [Manage data partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/). -{{% note %}} + +{{% /tab-content %}} +{{< /tabs-wrapper >}} + +{{% warn %}} #### Partition templates can only be applied on create You can only apply a partition template when creating a database. You can't update a partition template on an existing database. -{{% /note %}} - - -{{% /tab-content %}} -{{< /tabs-wrapper >}} +{{% /warn %}} ### Database naming restrictions diff --git a/content/influxdb/cloud-dedicated/admin/query-system-data.md b/content/influxdb/cloud-dedicated/admin/query-system-data.md index 1ca08a5b5..bd3d44b1e 100644 --- a/content/influxdb/cloud-dedicated/admin/query-system-data.md +++ b/content/influxdb/cloud-dedicated/admin/query-system-data.md @@ -31,7 +31,7 @@ performance of your {{< product-name omit=" Clustered" >}} cluster. #### System tables are subject to change System tables are not part of InfluxDB's stable API and may change with new releases. -The provided schema information and query examples are valid as of **April 11, 2024**. +The provided schema information and query examples are valid as of **August 22, 2024**. If you detect a schema change or a non-functioning query example, please [submit an issue](https://github.com/influxdata/docs-v2/issues/new/choose). diff --git a/content/influxdb/cloud-dedicated/admin/tables/create.md b/content/influxdb/cloud-dedicated/admin/tables/create.md index 5c89acd02..a49a08e2b 100644 --- a/content/influxdb/cloud-dedicated/admin/tables/create.md +++ b/content/influxdb/cloud-dedicated/admin/tables/create.md @@ -34,7 +34,7 @@ to a table, you must manually create the table before you write any data to it. to use in the partition template - _Optional_: [InfluxDB tag buckets](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#tag-bucket-part-templates) to use in the partition template - - _Optional_: A [Rust strftime date and time string](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#time-part-templates) + - _Optional_: A supported [Rust strftime date and time string](/influxdb/cloud-dedicated/admin/custom-partitions/partition-templates/#time-part-templates) that specifies the time format in the partition template and determines the time interval to partition by _(default is `%Y-%m-%d`)_ - The name of the database to create the table in @@ -71,9 +71,9 @@ If no template flags are provided, the table uses the partition template of the target database. For more information, see [Manage data partitioning](/influxdb/cloud-dedicated/admin/custom-partitions/). -{{% note %}} +{{% warn %}} #### Partition templates can only be applied on create You can only apply a partition template when creating a table. There is no way to update a partition template on an existing table. -{{% /note %}} +{{% /warn %}} diff --git a/content/influxdb/cloud-dedicated/reference/cli/influxctl/database/create.md b/content/influxdb/cloud-dedicated/reference/cli/influxctl/database/create.md index 6ef6e4f8e..8096cb225 100644 --- a/content/influxdb/cloud-dedicated/reference/cli/influxctl/database/create.md +++ b/content/influxdb/cloud-dedicated/reference/cli/influxctl/database/create.md @@ -156,8 +156,8 @@ influxctl database create \ ### Create a database with a custom partition template The following example creates a new `mydb` database and applies a partition -template that partitions by two tags (`room` and `sensor-type`) and by week using -the time format `%Y wk:%W`: +template that partitions by two tags (`room` and `sensor-type`) and by day using +the time format `%Y-%m-%d`: @@ -167,7 +167,7 @@ influxctl database create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,1000 \ - --template-timeformat '%Y wk:%W' \ + --template-timeformat '%Y-%m-%d' \ mydb ``` diff --git a/content/influxdb/cloud-dedicated/reference/cli/influxctl/table/create.md b/content/influxdb/cloud-dedicated/reference/cli/influxctl/table/create.md index fb0013ee1..dc817e362 100644 --- a/content/influxdb/cloud-dedicated/reference/cli/influxctl/table/create.md +++ b/content/influxdb/cloud-dedicated/reference/cli/influxctl/table/create.md @@ -82,8 +82,8 @@ influxctl table create DATABASE_NAME TABLE_NAME ### Create a table with a custom partition template The following example creates a new table and applies a partition -template that partitions by two tags (`room` and `sensor-type`) and by week using -the time format `%Y wk:%W`: +template that partitions by two tags (`room` and `sensor-type`) and by day using +the time format `%Y-%m-%d`: {{% code-placeholders "(DATABASE|TABLE)_NAME" %}} ```sh @@ -91,7 +91,7 @@ influxctl table create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,1000 \ - --template-timeformat '%Y wk:%W' \ + --template-timeformat '%Y-%m-%d' \ DATABASE_NAME \ TABLE_NAME ``` diff --git a/content/influxdb/clustered/admin/custom-partitions/best-practices.md b/content/influxdb/clustered/admin/custom-partitions/best-practices.md index 8429eaaa5..cdebf9f12 100644 --- a/content/influxdb/clustered/admin/custom-partitions/best-practices.md +++ b/content/influxdb/clustered/admin/custom-partitions/best-practices.md @@ -47,12 +47,9 @@ As you plan your partitioning strategy, keep in mind that data can be having to retrieve and read many partitions from the object store, which hurts query performance. -- Avoid using partition time intervals that are **less than one day**. - - The partition time interval should be balanced with the actual amount of data - written during each interval. If a single interval doesn't contain a lot of data, +- Balance the partition time interval with the actual amount of data written + during each interval. If a single interval doesn't contain a lot of data, it is better to partition by larger time intervals. - - Don't partition by tags that you typically don't use in your query workload. - Don't partition by distinct values of high-cardinality tags. Instead, [use tag buckets](#use-tag-buckets-for-high-cardinality-tags) to diff --git a/content/influxdb/clustered/admin/custom-partitions/define-custom-partitions.md b/content/influxdb/clustered/admin/custom-partitions/define-custom-partitions.md index ffd7d61c0..d471e0ad0 100644 --- a/content/influxdb/clustered/admin/custom-partitions/define-custom-partitions.md +++ b/content/influxdb/clustered/admin/custom-partitions/define-custom-partitions.md @@ -28,13 +28,13 @@ table. - [Create a table with a custom partition template](#create-a-table-with-a-custom-partition-template) - [Example partition templates](#example-partition-templates) -{{% note %}} +{{% warn %}} #### Partition templates can only be applied on create You can only apply a partition template when creating a database or table. You can't update a partition template on an existing resource. -{{% /note %}} +{{% /warn %}} Use the following command flags to identify [partition template parts](/influxdb/clustered/admin/custom-partitions/partition-templates/#tag-part-templates): @@ -69,7 +69,7 @@ Otherwise, InfluxDB omits time from the partition template and won't compact par The following example creates a new `example-db` database and applies a partition template that partitions by distinct values of two tags (`room` and `sensor-type`), -bucketed values of the `customerID` tag, and by week using the time format `%Y wk:%W`: +bucketed values of the `customerID` tag, and by day using the time format `%Y-%m-%d`: @@ -79,7 +79,7 @@ influxctl database create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,500 \ - --template-timeformat '%Y wk:%W' \ + --template-timeformat '%Y-%m-%d' \ example-db ``` @@ -150,22 +150,21 @@ prod,line=A,station=weld1 temp=81.9,qty=36i 1704067200000000000 ##### Partitioning by distinct tag values -| Description | Tag parts | Time part | Resulting partition key | +| Description | Tag parts | Time part | Resulting partition key | | :---------------------- | :---------------- | :--------- | :----------------------- | | By day (default) | | `%Y-%m-%d` | 2024-01-01 | -| By day (non-default) | | `%d %b %Y` | 01 Jan 2024 | -| By week | | `%Y wk:%W` | 2024 wk:01 | | By month | | `%Y-%m` | 2024-01 | -| Single tag, by day | `line` | `%F` | A \| 2024-01-01 | -| Single tag, by week | `line` | `%Y wk:%W` | A \| 2024 wk:01 | +| By year | | `%Y` | 2024 | +| Single tag, by day | `line` | `%Y-%m-%d` | A \| 2024-01-01 | | Single tag, by month | `line` | `%Y-%m` | A \| 2024-01 | -| Multiple tags, by day | `line`, `station` | `%F` | A \| weld1 \| 2024-01-01 | -| Multiple tags, by week | `line`, `station` | `%Y wk:%W` | A \| weld1 \| 2024 wk:01 | +| Single tag, by year | `line` | `%Y` | A \| 2024 | +| Multiple tags, by day | `line`, `station` | `%Y-%m-%d` | A \| weld1 \| 2024-01-01 | | Multiple tags, by month | `line`, `station` | `%Y-%m` | A \| weld1 \| 2024-01 | +| Multiple tags, by year | `line`, `station` | `%Y` | A \| weld1 \| 2024 | ##### Partition by tag buckets -| Description | Tag part | Tag bucket part | Time part | Resulting partition key | -| :--------------------------------- | :------- | :-------------- | :--------- | :---------------------- | -| Distinct tag, tag buckets, by day | `line` | `station,100` | `%F` | A \| 3 \| 2024-01-01 | -| Distinct tag, tag buckets, by week | `line` | `station,500` | `%Y wk:%W` | A \| 303 \| 2024 wk:01 | +| Description | Tag part | Tag bucket part | Time part | Resulting partition key | +| :---------------------------------- | :------- | :-------------- | :--------- | :---------------------- | +| Distinct tag, tag buckets, by day | `line` | `station,100` | `%Y-%m-%d` | A \| 3 \| 2024-01-01 | +| Distinct tag, tag buckets, by month | `line` | `station,500` | `%Y-%m` | A \| 303 \| 2024-01 | diff --git a/content/influxdb/clustered/admin/custom-partitions/partition-templates.md b/content/influxdb/clustered/admin/custom-partitions/partition-templates.md index 8d0b6daae..10ddd8c46 100644 --- a/content/influxdb/clustered/admin/custom-partitions/partition-templates.md +++ b/content/influxdb/clustered/admin/custom-partitions/partition-templates.md @@ -39,11 +39,6 @@ and only 1 time part. - [Tag part templates](#tag-part-templates) - [Tag bucket part templates](#tag-bucket-part-templates) - [Time part templates](#time-part-templates) - - [Date specifiers](#date-specifiers) - - [Time specifiers](#time-specifiers) - - [Time zone specifiers](#time-zone-specifiers) - - [Date and time specifiers](#date-and-time-specifiers) - - [Special specifiers](#special-specifiers) ## Restrictions @@ -109,175 +104,16 @@ unknown number of distinct values. ## Time part templates -Time part templates use [Rust strftime date and time formatting syntax](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) +Time part templates use a limited subset of the +[Rust strftime date and time formatting syntax](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) to specify time format in partition keys. -The smallest unit of time included in the time part template is the interval -used to partition data. - -{{% warn %}} -#### Avoid partitioning by less than one day - -We do not recommend using time intervals less than one day to partition data. -This can result in [over-partitioned data](/influxdb/clustered/admin/custom-partitions/best-practices/#avoid-over-partitioning) -and may hurt query performance. -{{% /warn %}} - -- [Date specifiers](#date-specifiers) -- [Time specifiers](#time-specifiers) -- [Time zone specifiers](#time-zone-specifiers) -- [Date and time specifiers](#date-and-time-specifiers) -- [Special specifiers](#special-specifiers) - -{{% note %}} -The following is adapted from the -[Rust strftime source code](https://docs.rs/chrono/latest/src/chrono/format/strftime.rs.html). -{{% /note %}} +InfluxDB uses the smallest unit of time included in the time part template as +the partition interval. ### Date specifiers -| Variable | Example | Description | -| :------: | :--------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `%Y` | `2001` | The full proleptic Gregorian year, zero-padded to 4 digits. chrono supports years from -262144 to 262143. Note: years before 1 BCE or after 9999 CE, require an initial sign (+/-). | -| `%C` | `20` | The proleptic Gregorian year divided by 100, zero-padded to 2 digits. [^1] | -| `%y` | `01` | The proleptic Gregorian year modulo 100, zero-padded to 2 digits. [^1] | -| `%m` | `07` | Month number (01--12), zero-padded to 2 digits. | -| `%b` | `Jul` | Abbreviated month name. Always 3 letters. | -| `%B` | `July` | Full month name. Also accepts corresponding abbreviation in parsing. | -| `%h` | `Jul` | Same as `%b`. | -| `%d` | `08` | Day number (01--31), zero-padded to 2 digits. | -| `%e` | ` 8` | Same as `%d` but space-padded. Same as `%_d`. | -| `%a` | `Sun` | Abbreviated weekday name. Always 3 letters. | -| `%A` | `Sunday` | Full weekday name. Also accepts corresponding abbreviation in parsing. | -| `%w` | `0` | Sunday = 0, Monday = 1, ..., Saturday = 6. | -| `%u` | `7` | Monday = 1, Tuesday = 2, ..., Sunday = 7. (ISO 8601) | -| `%U` | `28` | Week number starting with Sunday (00--53), zero-padded to 2 digits. [^2] | -| `%W` | `27` | Same as `%U`, but week 1 starts with the first Monday in that year instead. | -| `%G` | `2001` | Same as `%Y` but uses the year number in ISO 8601 week date. [^3] | -| `%g` | `01` | Same as `%y` but uses the year number in ISO 8601 week date. [^3] | -| `%V` | `27` | Same as `%U` but uses the week number in ISO 8601 week date (01--53). [^3] | -| `%j` | `189` | Day of the year (001--366), zero-padded to 3 digits. | -| `%D` | `07/08/01` | Month-day-year format. Same as `%m/%d/%y`. | -| `%x` | `07/08/01` | Locale's date representation (e.g., 12/31/99). | -| `%F` | `2001-07-08` | Year-month-day format (ISO 8601). Same as `%Y-%m-%d`. | -| `%v` | ` 8-Jul-2001` | Day-month-year format. Same as `%e-%b-%Y`. | - -### Time specifiers - -| Variable | Example | Description | -| :------: | :--------------------------------- | :----------------------------------------------------------------------------------------------------------------------- | -| `%H` | `00` | Hour number (00--23), zero-padded to 2 digits. | -| `%k` | ` 0` | Same as `%H` but space-padded. Same as `%_H`. | -| `%I` | `12` | Hour number in 12-hour clocks (01--12), zero-padded to 2 digits. | -| `%l` | `12` | Same as `%I` but space-padded. Same as `%_I`. | -| `%P` | `am` | `am` or `pm` in 12-hour clocks. | -| `%p` | `AM` | `AM` or `PM` in 12-hour clocks. | -| `%M` | `34` | Minute number (00--59), zero-padded to 2 digits. | -| `%S` | `60` | Second number (00--60), zero-padded to 2 digits. [^4] | -| `%f` | `26490000` | Number of nanoseconds since last whole second. [^7] | -| `%.f` | `.026490` | Decimal fraction of a second. Consumes the leading dot. [^7] | -| `%.3f` | `.026` | Decimal fraction of a second with a fixed length of 3. | -| `%.6f` | `.026490` | Decimal fraction of a second with a fixed length of 6. | -| `%.9f` | `.026490000` | Decimal fraction of a second with a fixed length of 9. | -| `%3f` | `026` | Decimal fraction of a second like `%.3f` but without the leading dot. | -| `%6f` | `026490` | Decimal fraction of a second like `%.6f` but without the leading dot. | -| `%9f` | `026490000` | Decimal fraction of a second like `%.9f` but without the leading dot. | -| `%R` | `00:34` | Hour-minute format. Same as `%H:%M`. | -| `%T` | `00:34:60` | Hour-minute-second format. Same as `%H:%M:%S`. | -| `%X` | `00:34:60` | Locale's time representation (e.g., 23:13:48). | -| `%r` | `12:34:60 AM` | Locale's 12 hour clock time. (e.g., 11:11:04 PM). Falls back to `%X` if the locale does not have a 12 hour clock format. | - -### Time zone specifiers - -| Variable | Example | Description | -| :------: | :--------------------------------- | :----------------------------------------------------------------------------------------------------------------- | -| `%Z` | `ACST` | Local time zone name. Skips all non-whitespace characters during parsing. Identical to `%:z` when formatting. [^8] | -| `%z` | `+0930` | Offset from the local time to UTC (with UTC being `+0000`). | -| `%:z` | `+09:30` | Same as `%z` but with a colon. | -| `%::z` | `+09:30:00` | Offset from the local time to UTC with seconds. | -| `%:::z` | `+09` | Offset from the local time to UTC without minutes. | -| `%#z` | `+09` | *Parsing only:* Same as `%z` but allows minutes to be missing or present. | - -### Date and time specifiers - -| Variable | Example | Description | -| :------: | :--------------------------------- | :--------------------------------------------------------------------- | -| `%c` | `Sun Jul 8 00:34:60 2001` | Locale's date and time (e.g., Thu Mar 3 23:05:25 2005). | -| `%+` | `2001-07-08T00:34:60.026490+09:30` | ISO 8601 / RFC 3339 date & time format. [^5] | -| `%s` | `994518299` | UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. [^6] | - -### Special specifiers - -| Variable | Example | Description | -| :------: | :------ | :---------------------- | -| `%t` | | Literal tab (`\t`). | -| `%n` | | Literal newline (`\n`). | -| `%%` | | Literal percent sign. | - -It is possible to override the default padding behavior of numeric specifiers `%?`. -This is not allowed for other specifiers and results in the `BAD_FORMAT` error. - -Modifier | Description --------- | ----------- -`%-?` | Suppresses any padding including spaces and zeroes. (e.g. `%j` = `012`, `%-j` = `12`) -`%_?` | Uses spaces as a padding. (e.g. `%j` = `012`, `%_j` = ` 12`) -`%0?` | Uses zeroes as a padding. (e.g. `%e` = ` 9`, `%0e` = `09`) - -Notes: - -[^1]: `%C`, `%y`: - This is floor division, so 100 BCE (year number -99) will print `-1` and `99` respectively. -[^2]: `%U`: - Week 1 starts with the first Sunday in that year. - It is possible to have week 0 for days before the first Sunday. - -[^3]: `%G`, `%g`, `%V`: - Week 1 is the first week with at least 4 days in that year. - Week 0 does not exist, so this should be used with `%G` or `%g`. - -[^4]: `%S`: - It accounts for leap seconds, so `60` is possible. - -[^5]: `%+`: Same as `%Y-%m-%dT%H:%M:%S%.f%:z`, i.e. 0, 3, 6 or 9 fractional - digits for seconds and colons in the time zone offset. -
-
- This format also supports having a `Z` or `UTC` in place of `%:z`. They - are equivalent to `+00:00`. -
-
- Note that all `T`, `Z`, and `UTC` are parsed case-insensitively. -
-
- The typical `strftime` implementations have different (and locale-dependent) - formats for this specifier. While Chrono's format for `%+` is far more - stable, it is best to avoid this specifier if you want to control the exact - output. - -[^6]: `%s`: - This is not padded and can be negative. - For the purpose of Chrono, it only accounts for non-leap seconds - so it slightly differs from ISO C `strftime` behavior. - -[^7]: `%f`, `%.f`: -
- `%f` and `%.f` are notably different formatting specifiers.
- `%f` counts the number of nanoseconds since the last whole second, while `%.f` is a fraction of a - second.
- Example: 7μs is formatted as `7000` with `%f`, and formatted as `.000007` with `%.f`. - -[^8]: `%Z`: - Since `chrono` is not aware of timezones beyond their offsets, this specifier - **only prints the offset** when used for formatting. The timezone abbreviation - will NOT be printed. See [this issue](https://github.com/chronotope/chrono/issues/960) - for more information. -
-
- Offset will not be populated from the parsed data, nor will it be validated. - Timezone is completely ignored. Similar to the glibc `strptime` treatment of - this format code. -
-
- It is not possible to reliably convert from an abbreviation to an offset, - for example CDT can mean either Central Daylight Time (North America) or - China Daylight Time. -*/ \ No newline at end of file +| Variable | Example | Description | +| :------: | :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `%Y` | `2001` | The full proleptic Gregorian year, zero-padded to 4 digits. chrono supports years from -262144 to 262143. Note: years before 1 BCE or after 9999 CE, require an initial sign (+/-). | +| `%m` | `07` | Month number (01--12), zero-padded to 2 digits. | +| `%d` | `08` | Day number (01--31), zero-padded to 2 digits. | diff --git a/content/influxdb/clustered/admin/custom-partitions/view-partitions.md b/content/influxdb/clustered/admin/custom-partitions/view-partitions.md new file mode 100644 index 000000000..b2fb64fab --- /dev/null +++ b/content/influxdb/clustered/admin/custom-partitions/view-partitions.md @@ -0,0 +1,198 @@ +--- +title: View partition information +description: > + Query partition information from InfluxDB v3 system tables to view partition + templates and verify partitions are working as intended. +menu: + influxdb_clustered: + name: View partitions + parent: Manage data partitioning +weight: 202 +list_code_example: | + ```sql + SELECT * FROM system.partitions WHERE table_name = 'example-table' + ``` +related: + - /influxdb/clustered/admin/query-system-data/ +--- + +{{< product-name >}} stores partition information in InfluxDB v3 system tables. +Query partition information to view partition templates and verify partitions +are working as intended. + +- [Query partition information from system tables](#query-partition-information-from-system-tables) +- [Partition-related queries](#partition-related-queries) + +{{% warn %}} +#### Querying system tables may impact overall cluster performance + +Partition information is stored in InfluxDB v3 system tables. +Querying system tables may impact the overall write and query performance of +your {{< product-name omit=" Clustered" >}} cluster. + + + +#### System tables are subject to change + +System tables are not part of InfluxDB's stable API and may change with new releases. +The provided schema information and query examples are valid as of **August 22, 2024**. +If you detect a schema change or a non-functioning query example, please +[submit an issue](https://github.com/influxdata/docs-v2/issues/new/choose). + + + +{{% /warn %}} + +## Query partition information from system tables + +Use the [`influxctl query` command](/influxdb/clustered/reference/cli/influxctl/query/) +and SQL to query partition-related information from InfluxDB system tables. + Provide the following: + +- **Enable system tables** with the `--enable-system-tables` command flag. +- **Database token**: A [database token](/influxdb/clustered/admin/tokens/#database-tokens) + with read permissions on the specified database. Uses the `token` setting from + the [`influxctl` connection profile](/influxdb/clustered/reference/cli/influxctl/#configure-connection-profiles) + or the `--token` command flag. +- **Database name**: The name of the database to query information about. + Uses the `database` setting from the + [`influxctl` connection profile](/influxdb/clustered/reference/cli/influxctl/#configure-connection-profiles) + or the `--database` command flag. +- **SQL query**: The SQL query to execute. + Pass the query in one of the following ways: + + - a string on the command line + - a path to a file that contains the query + - a single dash (`-`) to read the query from stdin + +{{% code-placeholders "DATABASE_(TOKEN|NAME)|SQL_QUERY" %}} + +```bash +influxctl query \ + --enable-system-tables \ + --database DATABASE_NAME \ + --token DATABASE_TOKEN \ + "SQL_QUERY" +``` + +{{% /code-placeholders %}} + +Replace the following: + +- {{% code-placeholder-key %}}`DATABASE_TOKEN`{{% /code-placeholder-key %}}: + A database token with read access to the specified database +- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: + The name of the database to query information about. +- {{% code-placeholder-key %}}`SQL_QUERY`{{% /code-placeholder-key %}}: + The SQL query to execute. For examples, see + [System query examples](#system-query-examples). + +When prompted, enter `y` to acknowledge the potential impact querying system +tables may have on your cluster. + +## Partition-related queries + +Use the following queries to return information about partitions in your +{{< product-name omit=" Clustered" >}} cluster. + +- [View partition templates of all tables](#view-partition-templates-of-all-tables) +- [View the partition template of a specific table](#view-the-partition-template-of-a-specific-table) +- [View all partitions for a table](#view-all-partitions-for-a-table) +- [View the number of partitions per table](#view-the-number-of-partitions-per-table) +- [View the number of partitions for a specific table](#view-the-number-of-partitions-for-a-specific-table) + +--- + +In the examples below, replace {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}} +with the name of the table you want to query information about. + +--- + +{{% code-placeholders "TABLE_NAME" %}} + +### View partition templates of all tables + +```sql +SELECT * FROM system.tables +``` + +#### Example results + +| table_name | partition_template | +| :--------- | :----------------------------------------------------------------------------------------- | +| weather | `{"parts":[{"timeFormat":"%Y-%m-%d"},{"bucket":{"tagName":"location","numBuckets":250}}]}` | +| home | `{"parts":[{"timeFormat":"%Y-%m-%d"},{"tagValue":"room"},{"tagValue":"sensor_id"}]}` | +| numbers | `{"parts":[{"timeFormat":"%Y"}]}` | + +{{% note %}} +If a table doesn't include a partition template in the output of this command, +the table uses the default (1 day) partition strategy and doesn't partition +by tags or tag buckets. +{{% /note %}} + +### View the partition template of a specific table + +```sql +SELECT * FROM system.tables WHERE table_name = 'TABLE_NAME' +``` + +#### Example results + +| table_name | partition_template | +| :--------- | :----------------------------------------------------------------------------------------- | +| weather | `{"parts":[{"timeFormat":"%Y-%m-%d"},{"bucket":{"tagName":"location","numBuckets":250}}]}` | + +### View all partitions for a table + +```sql +SELECT * FROM system.partitions WHERE table_name = 'TABLE_NAME' +``` + +### Example results + +| partition_id | table_name | partition_key | last_new_file_created_at | num_files | total_size_mb | +| -----------: | :--------- | :---------------- | -----------------------: | --------: | ------------: | +| 1362 | weather | 43 \| 2020-05-27 | 1683747418763813713 | 1 | 0 | +| 800 | weather | 234 \| 2021-08-02 | 1683747421899400796 | 1 | 0 | +| 630 | weather | 325 \| 2022-03-17 | 1683747417616689036 | 1 | 0 | +| 1401 | weather | 12 \| 2021-01-09 | 1683747417786122295 | 1 | 0 | +| 1012 | weather | 115 \| 2022-07-04 | 1683747417614219148 | 1 | 0 | + +### View the number of partitions per table + +```sql +SELECT + table_name, + COUNT(*) AS partition_count +FROM + system.partitions +GROUP BY + table_name +``` + +### Example results + +| table_name | partition_count | +| :--------- | --------------: | +| weather | 1096 | +| home | 24 | +| numbers | 1 | + +### View the number of partitions for a specific table + +```sql +SELECT + COUNT(*) AS partition_count +FROM + system.partitions +WHERE + table_name = 'TABLE_NAME' +``` + +### Example results + +| table_name | partition_count | +| :--------- | --------------: | +| weather | 1096 | + +{{% /code-placeholders %}} diff --git a/content/influxdb/clustered/admin/databases/create.md b/content/influxdb/clustered/admin/databases/create.md index 9b1d7a8b7..96c71dfc5 100644 --- a/content/influxdb/clustered/admin/databases/create.md +++ b/content/influxdb/clustered/admin/databases/create.md @@ -230,9 +230,9 @@ Use the `--template-tag`, `--template-tag-bucket, and `--template-timeformat` flags to define partition template parts used to generate partition keys for the database. For more information, see [Manage data partitioning](/influxdb/clustered/admin/custom-partitions/). -{{% note %}} +{{% warn %}} #### Partition templates can only be applied on create You can only apply a partition template when creating a database. You can't update a partition template on an existing database. -{{% /note %}} +{{% /warn %}} diff --git a/content/influxdb/clustered/admin/tables/create.md b/content/influxdb/clustered/admin/tables/create.md index cf0ee0c4e..e241a92cb 100644 --- a/content/influxdb/clustered/admin/tables/create.md +++ b/content/influxdb/clustered/admin/tables/create.md @@ -71,9 +71,9 @@ If no template flags are provided, the table uses the partition template of the target database. For more information, see [Manage data partitioning](/influxdb/clustered/admin/custom-partitions/). -{{% note %}} +{{% warn %}} #### Partition templates can only be applied on create You can only apply a partition template when creating a table. There is no way to update a partition template on an existing table. -{{% /note %}} +{{% /warn %}} diff --git a/content/influxdb/clustered/reference/cli/influxctl/database/create.md b/content/influxdb/clustered/reference/cli/influxctl/database/create.md index d18d7cbb0..3655cf412 100644 --- a/content/influxdb/clustered/reference/cli/influxctl/database/create.md +++ b/content/influxdb/clustered/reference/cli/influxctl/database/create.md @@ -155,8 +155,8 @@ influxctl database create \ ### Create a database with a custom partition template The following example creates a new `mydb` database and applies a partition -template that partitions by two tags (`room` and `sensor-type`) and by week using -the time format `%Y wk:%W`: +template that partitions by two tags (`room` and `sensor-type`) and by day using +the time format `%Y-%m-%d`: @@ -166,7 +166,7 @@ influxctl database create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,1000 \ - --template-timeformat '%Y wk:%W' \ + --template-timeformat '%Y-%m-%d' \ mydb ``` diff --git a/content/influxdb/clustered/reference/cli/influxctl/table/create.md b/content/influxdb/clustered/reference/cli/influxctl/table/create.md index 1d7d7792b..48c1c13b6 100644 --- a/content/influxdb/clustered/reference/cli/influxctl/table/create.md +++ b/content/influxdb/clustered/reference/cli/influxctl/table/create.md @@ -82,8 +82,8 @@ influxctl table create DATABASE_NAME TABLE_NAME ### Create a table with a custom partition template The following example creates a new table and applies a partition -template that partitions by two tags (`room` and `sensor-type`) and by week using -the time format `%Y wk:%W`: +template that partitions by two tags (`room` and `sensor-type`) and by day using +the time format `%Y-%m-%d`: {{% code-placeholders "(DATABASE|TABLE)_NAME" %}} ```sh @@ -91,7 +91,7 @@ influxctl table create \ --template-tag room \ --template-tag sensor-type \ --template-tag-bucket customerID,1000 \ - --template-timeformat '%Y wk:%W' \ + --template-timeformat '%Y-%m-%d' \ DATABASE_NAME \ TABLE_NAME ``` diff --git a/yarn.lock b/yarn.lock index cafc7ab6a..a9f404cd1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -534,9 +534,9 @@ eastasianwidth@^0.2.0: integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== electron-to-chromium@^1.5.4: - version "1.5.12" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.12.tgz#ee31756eaa2e06f2aa606f170b7ad06dd402b4e4" - integrity sha512-tIhPkdlEoCL1Y+PToq3zRNehUaKp3wBX/sr7aclAWdIWjvqAe/Im/H0SiCM4c1Q8BLPHCdoJTol+ZblflydehA== + version "1.5.13" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz#1abf0410c5344b2b829b7247e031f02810d442e6" + integrity sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q== emoji-regex@^8.0.0: version "8.0.0" @@ -831,9 +831,9 @@ http2-wrapper@^2.1.10: resolve-alpn "^1.2.0" hugo-extended@>=0.101.0: - version "0.132.2" - resolved "https://registry.yarnpkg.com/hugo-extended/-/hugo-extended-0.132.2.tgz#cca3d82d7ffd6145d535a787d3963215c8af075b" - integrity sha512-KsEeBOratmFHaX8RnJSnkrqy4HaYn+GctHJRtUtoZJZ/mE1knogBKeB4Ss6T3juBwBS9PVF7hb9XSkjeJUAo2Q== + version "0.133.0" + resolved "https://registry.yarnpkg.com/hugo-extended/-/hugo-extended-0.133.0.tgz#77ad49e1e394634337b7ce198053e670969fe836" + integrity sha512-+C3I/0uUww04mcdkRdcdsfqHlCXMRQrvi7dUqlyPQViDqIMszPzKQorKEB3YddYEJLomLKoUtAoxs2JVqTXT8A== dependencies: careful-downloader "^3.0.0" log-symbols "^5.1.0" @@ -875,9 +875,9 @@ is-binary-path@~2.1.0: binary-extensions "^2.0.0" is-core-module@^2.5.0: - version "2.15.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.15.0.tgz#71c72ec5442ace7e76b306e9d48db361f22699ea" - integrity sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA== + version "2.15.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.15.1.tgz#a7363a25bee942fefab0de13bf6aa372c82dcc37" + integrity sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ== dependencies: hasown "^2.0.2"