Compression
Compression is one of the key features of TimescaleDB and can speed up queries while drastically reducing storage requirements.
Info
Consult the Timescale docs to learn more about compression.
Usage
Compression is a configuration option for (virtual) hypertables and continuous aggregates. The only required argument is after
, referring to the time interval after which compression should be applied. This can be an interval or an integer depending on the data type of your time column.
models/my_hypertable.sql
{{
config(
materialized='hypertable',
main_dimension={"column_name": "time_column"},
compression={
"after": "interval '1 day'",
}
)
}}
select current_timestamp as time_column
dbt_project.yml
models:
your_project_name:
folder_containing_the_hypertables:
+materialized: hypertable
+compression: false # (1)!
model_one:
+main_dimension:
column_name: time_column
+compression:
after: interval '1 day'
model_two:
+main_dimension:
column_name: time_column_in_model_two
+compression:
after: interval '1 hour'
chunk_time_interval: 1 day
orderby: 'another_column'
segmentby: ['column_one', 'column_two']
# ...
- This is the default value and the same as leaving out the
compression
key entirely.
Configuration options
The after
option from the compression policy settings is the only required option.
Compression settings
orderby
(string)segmentby
(list of strings)chunk_time_interval
(the actual interval, not prefixed with "interval")
Info
Consult the Timescale docs for more information regarding these settings.
Compression policy settings
after
(interval or integer depending on your time column)schedule_interval
(interval)initial_start
timezone
Info
Consult the Timescale docs for more information regarding these settings.