Skip to content
Merged
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
26 changes: 26 additions & 0 deletions use-timescale/hypercore/compression-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,32 @@ have a lot of repeated values, then the dictionary is the same size as the
original data. TimescaleDB automatically detects this case, and falls back to
not using a dictionary in that scenario.

#### JSONB compression

For JSONB columns, TimescaleDB uses a two-layer compression approach:

1. **TimescaleDB dictionary compression**: First, TimescaleDB attempts to apply
its own dictionary compression to the JSONB data. This works well when JSONB
values have high repetition.

2. **PostgreSQL TOAST compression**: If dictionary compression doesn't perform
well (for example, when each JSONB value is unique or nearly unique),
TimescaleDB skips compression and allows PostgreSQL to handle the data using
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TimescaleDB skips compression and allows PostgreSQL to handle the data using
$PG to handle the data using

its TOAST (The Oversized-Attribute Storage Technique) compression. By default,
PostgreSQL uses `pglz` compression, but this can be configured to use more
modern compression algorithms like `lz4` by setting the `default_toast_compression`
configuration parameter.

You can check your current TOAST compression setting:

```sql
SHOW default_toast_compression;
```

This two-layer approach ensures that JSONB data is compressed efficiently
regardless of its characteristics, using dictionary compression when beneficial
and falling back to LZ-based compression when dictionary compression is not effective.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


[decompress-chunks]: /use-timescale/:currentVersion:/compression/decompress-chunks
[manual-compression]: /use-timescale/:currentVersion:/compression/manual-compression/
[delta]: /use-timescale/:currentVersion:/hypercore/compression-methods/#delta-encoding
Expand Down