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

# Decompression

> Manually decompress compressed chunks by name, time, or more precise constraints

export const HYPERTABLE = 'hypertable';

export const ROWSTORE = 'rowstore';

<Icon icon="archive" iconType="duotone" /> Old API since [2.18.0][tsdb-2.18.0]. Superseded by
[`convert_to_rowstore`][convert-to-rowstore]. However, compression APIs are still supported, you do not need to migrate
to the hypercore APIs.

<Warning>
  When compressing your data, you can reduce the amount of storage space used. But you should always leave some additional
  storage capacity. This gives you the flexibility to decompress chunks when necessary, for actions such as bulk inserts.
</Warning>

This section describes commands to use for decompressing chunks. You can filter by time to select the chunks you want to
decompress.

## Decompress chunks manually

Before decompressing chunks, stop any compression policy on the {HYPERTABLE} you are decompressing. The database
automatically recompresses your chunks in the next scheduled job. If you accumulate a large amount of chunks that need
to be compressed, the [troubleshooting guide][troubleshooting-oom-chunks] shows how to compress a backlog of chunks. For
more information on how to stop and run compression policies using `alter_job()`, see the [API reference][alter_job].

There are several methods for selecting chunks and decompressing them.

### Decompress individual chunks

To decompress a single chunk by name, run this command:

```sql theme={"dark"}
SELECT decompress_chunk('_timescaledb_internal.<chunk_name>');
```

where, `<chunk_name>` is the name of the chunk you want to decompress.

### Decompress chunks by time

To decompress a set of chunks based on a time range, you can use the output of `show_chunks` to decompress each one:

```sql theme={"dark"}
SELECT decompress_chunk(c, true)
    FROM show_chunks('table_name', older_than, newer_than) c;
```

For more information about the `decompress_chunk` function, see the `decompress_chunk` [API
reference][api-reference-decompress].

### Decompress chunks on more precise constraints

If you want to use more precise matching constraints, for example space partitioning, you can construct a command like
this:

```sql theme={"dark"}
SELECT tableoid::regclass FROM metrics
  WHERE time = '2000-01-01' AND device_id = 1
  GROUP BY tableoid;

                 tableoid
------------------------------------------
 _timescaledb_internal._hyper_72_37_chunk
```

[alter_job]: /api-reference/timescaledb/jobs-and-automation/alter_job

[api-reference-decompress]: /api-reference/timescaledb/compression/decompress_chunk

[convert-to-rowstore]: /api-reference/hypercore/convert_to_rowstore

[troubleshooting-oom-chunks]: /manage-data/capabilities/hypercore/troubleshooting#out-of-memory-errors-after-enabling-the-columnstore

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