Tiger Cloud: Performance, Scale, Enterprise, Free
Self-hosted products
MST
Merge two or more chunks into one.
The partition boundaries for the new chunk is the union of all partitions of the merged chunks. The new chunk retains the name, constraints, and triggers of the first chunk in the partition order.
You can only merge chunks that have directly adjacent partitions. It is not possible to merge chunks that have another chunk, or an empty range between them in any of the partitioning dimensions.
Chunk merging has the following limitations. You cannot:
- Merge chunks with tiered data
- Write to chunks that are being merged
When a merge is executed using the concurrently option, other processes can
simultaneously read from the chunks being merged and insert into other chunks.
The merge happens across two transactions: the first one rewrites the chunks
into a temporary relation without taking any locks that prevent reads, while
the second transaction locks out all other operations before swapping the old
relations for the new one. The second operation completes quickly so it
should not significantly affect other operations.
If a concurrent merge fails or is aborted during the second transaction, the
temporary relation might be left on disk. This could consume significant disk
space. To clean up such non-completed merges, use the procedure
_timescaledb_functions.chunk_rewrite_cleanup().
Merge two chunks:
CALL merge_chunks('_timescaledb_internal._hyper_1_1_chunk', '_timescaledb_internal._hyper_1_2_chunk');Merge more than two chunks:
CALL merge_chunks('{_timescaledb_internal._hyper_1_1_chunk, _timescaledb_internal._hyper_1_2_chunk, _timescaledb_internal._hyper_1_3_chunk}');Merge two chunks concurrently, allowing reads:
CALL merge_chunks('_timescaledb_internal._hyper_1_1_chunk', '_timescaledb_internal._hyper_1_2_chunk', concurrently => true);To merge more than two chunks concurrently, use
merge_chunks_concurrently().
You can merge either two chunks, or an arbitrary number of chunks specified as an array of chunk identifiers.
When you call merge_chunks, you must specify either chunk1 and chunk2, or chunks. You cannot use both
arguments.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
chunk1, chunk2 | REGCLASS | - | ✖ | The two chunk to merge in partition order |
chunks | REGCLASS[] | - | ✖ | The array of chunks to merge in partition order |
concurrently | BOOL. | false | ✖ | If set to true allow reads on the merging chunks |
Keywords
Found an issue on this page?Report an issue or Edit this page
in GitHub.