> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# set_chunk_time_interval()

> Change the chunk time interval of a hypertable

export const CAGG = 'continuous aggregate';

export const CHUNK_CAP = 'Chunk';

export const CHUNK = 'chunk';

export const HYPERTABLE_CAP = 'Hypertable';

export const HYPERTABLE = 'hypertable';

<Icon icon="tag" iconType="duotone" /> Since [0.1.0][tsdb-0.1.0]

Sets the `chunk_time_interval` on a {HYPERTABLE}. The new interval is used
when new {CHUNK}s are created, and time intervals on existing {CHUNK}s are
not changed.

## Samples

For a TIMESTAMP column, set `chunk_time_interval` to 24 hours:

```sql theme={"dark"}
SELECT set_chunk_time_interval('conditions', INTERVAL '24 hours');
SELECT set_chunk_time_interval('conditions', 86400000000);
```

For a time column expressed as the number of milliseconds since the
UNIX epoch, set `chunk_time_interval` to 24 hours:

```sql theme={"dark"}
SELECT set_chunk_time_interval('conditions', 86400000);
```

## Arguments

The syntax is:

```sql theme={"dark"}
SELECT set_chunk_time_interval(
    hypertable = '<hypertable_name>',
    chunk_time_interval = <interval>,
    dimension_name = '<dimension_name>'
);
```

| Name                  | Type     | Default | Required | Description                                                                                                                                        |
| --------------------- | -------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hypertable`          | REGCLASS | -       | ✔        | {HYPERTABLE} or {CAGG} to update interval for.                                                                                                     |
| `chunk_time_interval` | See note | -       | ✔        | Event time that each new {CHUNK} covers.                                                                                                           |
| `dimension_name`      | NAME     | `NULL`  | ✖        | The name of the time dimension to set the number of partitions for. Only use `dimension_name` when your {HYPERTABLE} has multiple time dimensions. |

If you change {CHUNK} time interval you may see a {CHUNK} that is smaller than the new interval. For example, if you
have two 7-day {CHUNK}s that cover 14 days, then change `chunk_time_interval` to 3 days, you may end up with a
transition {CHUNK} covering one day. This happens because the start and end of the new {CHUNK} is calculated based on
dividing the timeline by the `chunk_time_interval` starting at epoch 0. This leads to the following {CHUNK}s
\[0, 3), \[3, 6), \[6, 9), \[9, 12), \[12, 15), \[15, 18) and so on. The two 7-day {CHUNK}s covered data up to day 14:
\[0, 7), \[8, 14), so the 3-day {CHUNK} for \[12, 15) is reduced to a one day {CHUNK}. The following {CHUNK} \[15, 18) is
created as a full 3 day {CHUNK}.

The valid types for the `chunk_time_interval` depend on the type used for the
{HYPERTABLE} `time` column:

| `time` column type | `chunk_time_interval` type | Time unit                               |
| ------------------ | -------------------------- | --------------------------------------- |
| TIMESTAMP          | INTERVAL                   | days, hours, minutes, etc               |
|                    | INTEGER or BIGINT          | microseconds                            |
| TIMESTAMPTZ        | INTERVAL                   | days, hours, minutes, etc               |
|                    | INTEGER or BIGINT          | microseconds                            |
| DATE               | INTERVAL                   | days, hours, minutes, etc               |
|                    | INTEGER or BIGINT          | microseconds                            |
| SMALLINT           | SMALLINT                   | The same time unit as the `time` column |
| INT                | INT                        | The same time unit as the `time` column |
| BIGINT             | BIGINT                     | The same time unit as the `time` column |

For more information, see [{HYPERTABLE} partitioning][hypertable-partitioning].

## Returns

This function returns void.

[hypertable-partitioning]: /use-timescale/hypertables/#hypertable-partitioning

[tsdb-0.1.0]: https://github.com/timescale/timescaledb/releases/tag/0.1.0
