> ## 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.

# timescaledb_information.chunks

> Get metadata about hypertable chunks

export const TIMESCALE_DB = 'TimescaleDB';

export const HYPERTABLE = 'hypertable';

export const CHUNK = 'chunk';

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

Get metadata about the {CHUNK}s of {HYPERTABLE}s.

This view shows metadata for the {CHUNK}'s primary time-based dimension.
For information about a {HYPERTABLE}'s secondary dimensions,
the [dimensions view][dimensions] should be used instead.

If the {CHUNK}'s primary dimension is of a time datatype, `range_start` and
`range_end` are set. Otherwise, if the primary dimension type is integer based,
`range_start_integer` and `range_end_integer` are set.

## Samples

Get information about the {CHUNK}s of a {HYPERTABLE}.

<Info>
  Dimension builder `by_range` was introduced in {TIMESCALE_DB} 2.13.
  The `chunk_creation_time` metadata was introduced in {TIMESCALE_DB} 2.13.
</Info>

```sql theme={"dark"}
CREATE TABLESPACE tablespace1 location '/usr/local/pgsql/data1';

CREATE TABLE hyper_int (a_col integer, b_col integer, c integer);
SELECT create_hypertable('hyper_int', by_range('a_col', 10));
CREATE OR REPLACE FUNCTION integer_now_hyper_int() returns int LANGUAGE SQL STABLE as $$ SELECT coalesce(max(a_col), 0) FROM hyper_int $$;
SELECT set_integer_now_func('hyper_int', 'integer_now_hyper_int');

INSERT INTO hyper_int SELECT generate_series(1,5,1), 10, 50;

SELECT attach_tablespace('tablespace1', 'hyper_int');
INSERT INTO hyper_int VALUES( 25 , 14 , 20), ( 25, 15, 20), (25, 16, 20);

SELECT * FROM timescaledb_information.chunks WHERE hypertable_name = 'hyper_int';

-[ RECORD 1 ]----------+----------------------
hypertable_schema      | public
hypertable_name        | hyper_int
chunk_schema           | _timescaledb_internal
chunk_name             | _hyper_7_10_chunk
primary_dimension      | a_col
primary_dimension_type | integer
range_start            |
range_end              |
range_start_integer    | 0
range_end_integer      | 10
is_compressed          | f
chunk_tablespace       |
-[ RECORD 2 ]----------+----------------------
hypertable_schema      | public
hypertable_name        | hyper_int
chunk_schema           | _timescaledb_internal
chunk_name             | _hyper_7_11_chunk
primary_dimension      | a_col
primary_dimension_type | integer
range_start            |
range_end              |
range_start_integer    | 20
range_end_integer      | 30
is_compressed          | f
chunk_tablespace       | tablespace1
```

## Returns

| Name                     | Type                     | Description                                                                            |
| ------------------------ | ------------------------ | -------------------------------------------------------------------------------------- |
| `hypertable_schema`      | TEXT                     | Schema name of the hypertable                                                          |
| `hypertable_name`        | TEXT                     | Table name of the hypertable                                                           |
| `chunk_schema`           | TEXT                     | Schema name of the chunk                                                               |
| `chunk_name`             | TEXT                     | Name of the chunk                                                                      |
| `primary_dimension`      | TEXT                     | Name of the column that is the primary dimension                                       |
| `primary_dimension_type` | REGTYPE                  | Type of the column that is the primary dimension                                       |
| `range_start`            | TIMESTAMP WITH TIME ZONE | Start of the range for the {CHUNK}'s dimension                                         |
| `range_end`              | TIMESTAMP WITH TIME ZONE | End of the range for the {CHUNK}'s dimension                                           |
| `range_start_integer`    | BIGINT                   | Start of the range for the {CHUNK}'s dimension, if the dimension type is integer based |
| `range_end_integer`      | BIGINT                   | End of the range for the {CHUNK}'s dimension, if the dimension type is integer based   |
| `is_compressed`          | BOOLEAN                  | Is the {CHUNK} in the columnstore?                                                     |
| `chunk_tablespace`       | TEXT                     | Tablespace used by the {CHUNK}                                                         |

\| `chunk_creation_time` | TIMESTAMP WITH TIME ZONE | The time when this {CHUNK} was created for data addition |

[dimensions]: /api-reference/timescaledb/informational-views/dimensions

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