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

# convert_to_columnstore()

> Manually add a chunk to the columnstore

export const CHUNK = 'chunk';

export const HYPERTABLE = 'hypertable';

export const COLUMNSTORE = 'columnstore';

export const ROWSTORE = 'rowstore';

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

<Tag>Community</Tag>

<Info>
  `convert_to_columnstore()` replaces `compress_chunk()`, deprecated in 2.18.0.
</Info>

Manually convert a specific {CHUNK} in the {HYPERTABLE} {ROWSTORE} to the {COLUMNSTORE}.

Although `convert_to_columnstore` gives you more fine-grained control, best practice is to use
[`add_columnstore_policy`][add_columnstore_policy]. You can also add {CHUNK}s to the {COLUMNSTORE} at a specific time
[running the job associated with your {COLUMNSTORE} policy][run-job] manually.

To move a {CHUNK} from the {COLUMNSTORE} back to the {ROWSTORE}, use [`convert_to_rowstore`][convert_to_rowstore].

## Samples

To convert a single {CHUNK} to {COLUMNSTORE}:

```sql theme={"dark"}
CALL convert_to_columnstore('_timescaledb_internal._hyper_1_2_chunk');
```

## Arguments

The syntax is:

```sql theme={"dark"}
CALL convert_to_columnstore(
    chunk = '<chunk_name>',
    if_not_columnstore = true | false,
    recompress = true | false
);
```

| Name                 | Type     | Default | Required | Description                                                                                                             |
| -------------------- | -------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `chunk`              | REGCLASS | -       | ✔        | Name of the {CHUNK} to add to the {COLUMNSTORE}.                                                                        |
| `if_not_columnstore` | BOOLEAN  | `true`  | ✖        | Set to `false` so this call fails with an error rather than a warning if `chunk` is already in the {COLUMNSTORE}.       |
| `recompress`         | BOOLEAN  | `false` | ✖        | Set to `true` to recompress. In-memory recompression is attempted first; it falls back to internal decompress/compress. |

## Returns

This function returns void.

[add_columnstore_policy]: /api-reference/timescaledb/hypercore/add_columnstore_policy

[convert_to_rowstore]: /api-reference/timescaledb/hypercore/convert_to_rowstore

[run-job]: /api-reference/timescaledb/jobs-automation/run_job

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