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

> Move a chunk from the columnstore to the rowstore

export const HYPERTABLE = 'hypertable';

export const CHUNK = 'chunk';

export const TIMESCALE_DB = 'TimescaleDB';

export const ROWSTORE = 'rowstore';

export const COLUMNSTORE = 'columnstore';

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

<Tag>Community</Tag>

<Info>
  `convert_to_rowstore()` replaces `decompress_chunk()`, deprecated in 2.18.0.
</Info>

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

If you need to modify or add a lot of data to a {CHUNK} in the {COLUMNSTORE}, best practice is to stop
any [jobs][job] moving {CHUNK}s to the {COLUMNSTORE}, convert the {CHUNK} back to the {ROWSTORE}, then modify the
data. After the update, [convert the {CHUNK} to the {COLUMNSTORE}][convert_to_columnstore] and restart the jobs.
This workflow is especially useful if you need to backfill old data.

## Samples

To modify or add a lot of data to a {CHUNK}:

1. **Stop the jobs that are automatically adding {CHUNK}s to the {COLUMNSTORE}**

   Retrieve the list of jobs from the [timescaledb\_information.jobs][informational-views] view
   to find the job you need to [alter\_job][alter_job].

   ```sql theme={"dark"}
   SELECT alter_job(JOB_ID, scheduled => false);
   ```

2. **Convert a {CHUNK} to update back to the {ROWSTORE}**

   ```sql theme={"dark"}
   CALL convert_to_rowstore('_timescaledb_internal._hyper_2_2_chunk');
   ```

3. **Update the data in the {CHUNK} you added to the {ROWSTORE}**

   Best practice is to structure your [INSERT][insert] statement to include appropriate
   partition key values, such as the timestamp. {TIMESCALE_DB} adds the data to the correct {CHUNK}:

   ```sql theme={"dark"}
   INSERT INTO metrics (time, value)
   VALUES ('2025-01-01T00:00:00', 42);
   ```

4. **Convert the updated {CHUNK}s back to the {COLUMNSTORE}**

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

5. **Restart the jobs that are automatically converting {CHUNK}s to the {COLUMNSTORE}**

   ```sql theme={"dark"}
   SELECT alter_job(JOB_ID, scheduled => true);
   ```

[alter_job]: /api-reference/timescaledb/actions/alter_job/

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

[insert]: /manage-data/capabilities/write-data/insert/

[setup-hypercore]: /manage-data/capabilities/hypercore/real-time-analytics-in-hypercore/

[compression_alter-table]: /api-reference/timescaledb/hypercore/alter_table/

## Arguments

The syntax is:

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

| Name             | Type     | Default | Required | Description                                                                                                  |
| ---------------- | -------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| `chunk`          | REGCLASS | -       | ✔        | Name of the {CHUNK} to be moved to the {ROWSTORE}.                                                           |
| `if_columnstore` | BOOLEAN  | `true`  | ✖        | Set to `false` so this call fails with an error rather than a warning if `chunk` is not in the {COLUMNSTORE} |

## Returns

This function returns void.

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

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

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

[insert]: /manage-data/capabilities/write-data/insert

[job]: /api-reference/timescaledb/jobs-automation/index

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