---
title: reorder_chunk() | Tiger Data Docs
description: Reorder rows in a chunk
---

Since [1.2.0](https://github.com/timescale/timescaledb/releases/tag/1.2.0)

Reorder a single chunk‘s heap to follow the order of an index. This function acts similarly to the [PostgreSQL CLUSTER command](https://www.postgresql.org/docs/current/sql-cluster.html) , however it uses lower lock levels so that, unlike with the CLUSTER command, the chunk and hypertable are able to be read for most of the process. It does use a bit more disk space during the operation.

This command can be particularly useful when data is often queried in an order different from that in which it was originally inserted. For example, data is commonly inserted into a hypertable in loose time order (for example, many devices concurrently sending their current state), but one might typically query the hypertable about a *specific* device. In such cases, reordering a chunk using an index on `(device_id, time)` can lead to significant performance improvement for these types of queries.

One can call this function directly on individual chunks of a hypertable, but using [add\_reorder\_policy](/docs/reference/timescaledb/hypertables/add_reorder_policy/index.md) is often much more convenient.

## Samples

Reorder a chunk on an index:

```
SELECT reorder_chunk('_timescaledb_internal._hyper_1_10_chunk', '_timescaledb_internal.conditions_device_id_time_idx');
```

## Arguments

The syntax is:

```
SELECT reorder_chunk(
    chunk = '<chunk_name>',
    index = '<index_name>',
    verbose = true | false
);
```

| Name      | Type     | Default | Required | Description                                                                  |
| --------- | -------- | ------- | -------- | ---------------------------------------------------------------------------- |
| `chunk`   | REGCLASS | -       | ✔        | Name of the chunk to reorder.                                                |
| `index`   | REGCLASS | -       | ✖        | The name of the index (on either the hypertable or chunk) to order by.       |
| `verbose` | BOOLEAN  | `FALSE` | ✖        | Setting to true displays messages about the progress of the reorder command. |

## Returns

This function returns void.
