> ## 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_approximate_size()

> Get the approximate total disk space used by a hypertable

export const PG = 'Postgres';

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 [2.14.0][tsdb-2.14.0]

Get the approximate 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_approximate_detailed_size` function.

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

<Note>
  This function relies on the per backend caching using the in-built
  {PG} storage manager layer to compute the approximate size
  cheaply. The PG cache invalidation clears off the cached size for a
  {CHUNK} when DML happens into it. That size cache is thus able to get
  the latest size in a matter of minutes. Also, due to the backend
  caching, any long running session will only fetch latest data for new
  or modified {CHUNK}s and can use the cached data (which is calculated
  afresh the first time around) effectively for older {CHUNK}s. Thus it
  is recommended to use a single connected {PG} backend session to
  compute the approximate sizes of {HYPERTABLE}s to get faster results.
</Note>

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

## Samples

Get the approximate size information for a {HYPERTABLE}.

```sql theme={"dark"}
SELECT * FROM hypertable_approximate_size('devices');
 hypertable_approximate_size
-----------------------------
                        8192
```

Get the approximate size information for all {HYPERTABLE}s.

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

Get the approximate size information for a {CAGG}.

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

 hypertable_approximate_size
-----------------------------
                        8192
```

## Arguments

The syntax is:

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

| Name         | Type     | Default | Required | Description                                         |
| ------------ | -------- | ------- | -------- | --------------------------------------------------- |
| `hypertable` | REGCLASS | -       | ✔        | Hypertable or continuous aggregate to show size of. |

## Returns

| Column                        | Type   | Description                                                                                           |
| ----------------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| hypertable\_approximate\_size | BIGINT | Total approximate 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-2.14.0]: https://github.com/timescale/timescaledb/releases/tag/2.14.0
