Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _partials/_early_access_2_23_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Tag variant="hollow">Early access: [TimescaleDB v2.23.0](https://github.com/timescale/timescaledb/releases/tag/2.23.0)</Tag>
1 change: 1 addition & 0 deletions _partials/_since_2_23_0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Tag variant="hollow">Since [TimescaleDB v2.23.0](https://github.com/timescale/timescaledb/releases/tag/2.23.0)</Tag>
36 changes: 36 additions & 0 deletions use-timescale/write-data/insert.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ keywords: [ingest]
tags: [insert, write, hypertables]
---

import EarlyAccess2230 from "versionContent/_partials/_early_access_2_23_0.mdx";

# Insert data

Insert data into a hypertable with a standard [`INSERT`][postgres-insert] SQL
Expand Down Expand Up @@ -65,4 +67,38 @@ time | location | temperature | humidity
(1 row)
```

## Direct compress on INSERT

When you create a $HYPERTABLE using [CREATE TABLE ... WITH ...][hypertable-create-table], $TIMESCALE_DB creates a
[columnstore policy][add_columnstore_policy] that automatically converts your data to the $COLUMNSTORE after an interval
that matches the default [chunk_interval][create_table_arguments]. This columnar format enables fast scanning and
aggregation, optimizing performance for analytical workloads while also saving significant storage space. In the
$COLUMNSTORE conversion, $HYPERTABLE chunks are compressed by up to 98%, and organized for efficient, large-scale
queries.

To improve performance, you can compress data during `INSERT` so that it is injected directly into chunks
in the $COLUMNSTORE rather than waiting for the policy.

To enable direct compress on INSERT, enable the following [GUC parameters][gucs]:

```sql
SET timescaledb.enable_compressed_insert = true;
SET timescaledb.enable_compressed_insert_sort_batches = true;
SET timescaledb.enable_compressed_insert_client_sorted = true;
```

When you set `enable_compressed_insert_client_sorted` to `true`, you must ensure that data in the input
stream is sorted.

<EarlyAccess2230 />

[postgres-update]: https://www.postgresql.org/docs/current/sql-update.html
[hypertable-create-table]: /api/:currentVersion:/hypertable/create_table/
[add_columnstore_policy]: /api/:currentVersion:/hypercore/add_columnstore_policy/
[remove_columnstore_policy]: /api/:currentVersion:/hypercore/remove_columnstore_policy/
[create_table_arguments]: /api/:currentVersion:/hypertable/create_table/#arguments
[alter_job_samples]: /api/:currentVersion:/jobs-automation/alter_job/#samples
[convert_to_columnstore]: /api/:currentVersion:/hypercore/convert_to_columnstore/
[gucs]: /api/:currentVersion:/configuration/gucs/

[postgres-insert]: https://www.postgresql.org/docs/current/sql-insert.html