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

# hypertable_size()

> Get the total disk space used by 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.2.0][tsdb-0.2.0]

Get the total disk space used by a {HYPERTABLE} or {CAGG},
that is, the sum of the size for the table itself including {CHUNK}s,
any indexes on the table, and any toast tables. The size is reported
in bytes. This is equivalent to computing the sum of `total_bytes`
column from the output of `hypertable_detailed_size` function.

<Note>
  When a {CAGG} name is provided, the function
  transparently looks up the backing {HYPERTABLE} and returns its statistics
  instead.
</Note>

For more information about using {HYPERTABLE}s, including {CHUNK} size partitioning,
see the [hypertable section][hypertable-docs].

## Samples

Get the size information for a {HYPERTABLE}.

```sql theme={"dark"}
SELECT hypertable_size('devices');

 hypertable_size
-----------------
           73728
```

Get the size information for all {HYPERTABLE}s.

```sql theme={"dark"}
SELECT hypertable_name, hypertable_size(format('%I.%I', hypertable_schema, hypertable_name)::regclass)
  FROM timescaledb_information.hypertables;
```

Get the size information for a {CAGG}.

```sql theme={"dark"}
SELECT hypertable_size('device_stats_15m');

 hypertable_size
-----------------
           73728
```

## Arguments

The syntax is:

```sql theme={"dark"}
SELECT hypertable_size(
    hypertable = '<hypertable_name>'
);
```

| Name         | Type     | Default | Required | Description                             |
| ------------ | -------- | ------- | -------- | --------------------------------------- |
| `hypertable` | REGCLASS | -       | ✔        | {HYPERTABLE} or {CAGG} to show size of. |

## Returns

| Name             | Type   | Description                                                                               |
| ---------------- | ------ | ----------------------------------------------------------------------------------------- |
| hypertable\_size | BIGINT | Total disk space used by the specified {HYPERTABLE}, including all indexes and TOAST data |

<Note>
  `NULL` is returned if the function is executed on a non-{HYPERTABLE} relation.
</Note>

[hypertable-docs]: /use-timescale/hypertables/

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