- Row-based storage for recent data: the most recent chunk (and possibly more) is always stored in the rowstore, ensuring fast inserts, updates, and low-latency single record queries. Additionally, row-based storage is used as a writethrough for inserts and updates to columnar storage.
- Columnar storage for analytical performance: chunks are automatically compressed into the columnstore, optimizing storage efficiency and accelerating analytical queries.
Is converted and compressed into arrays in a row in the columnstore:
Because a single row takes up less disk space, you can reduce your chunk size by up to 98%, and can also
speed up your queries. This saves on storage costs, and keeps your queries operating at lightning speed.
For an in-depth explanation of how hypertables and hypercore work, see the Data model.
This page shows you how to get the best results when you set a policy to automatically convert chunks in a
hypertable from the rowstore to the columnstore.
Prerequisites
To follow the steps on this page:- Create a target Tiger Cloud service with Real-time analytics enabled. You need your connection details. This procedure also works for self-hosted TimescaleDB.
Optimize your data with columnstore policies
The following figure shows the workflow to follow when you setup hypercore. The compression ratio and query performance of data in the columnstore is dependent on the order and structure of your data. Rows that change over a dimension should be close to each other. With time-series data, youorderby the time
dimension. For example, Timestamp:
This ensures that records are compressed and accessed in the same order. However, you would always have to
access the data using the time dimension, then filter all the rows using other criteria. To make your queries more
efficient, you segment your data based on the following:
- The way you want to access it. For example, to rapidly access data about a
single device, you
segmentbytheDevice IDcolumn. This enables you to run much faster analytical queries on data in the columnstore. - The compression rate you want to achieve. The lower the cardinality of the
segmentbycolumn, the better compression results you get.
segmentby and orderby parameters when
you write to and read from the columnstore.
To set up your hypercore automation:
- Connect to your service In Tiger Console open an SQL editor. You can also connect to your service using psql.
-
Enable columnstore on a hypertable
For efficient queries, remember to
segmentbythe column you will use most often to filter your data. For example:-
Hypertables:
Use
CREATE TABLEfor a hypertableWhen you create a hypertable usingCREATE TABLE ... WITH ..., the default partitioning column is automatically the first column with a timestamp data type. Also, TimescaleDB creates a columnstore policy that automatically converts your data to the columnstore, after an interval equal to the value of thechunk_interval, defined throughcompress_afterin the policy. 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. You can customize this policy later usingalter_job. However, to changeafterorcreated_before, the compression settings, or the hypertable the policy is acting on, you must remove the columnstore policy and add a new one. You can also manually convert chunks in a hypertable to the columnstore. -
Continuous aggregates
-
Use
ALTER MATERIALIZED VIEWfor a continuous aggregate:Before you say “huh”, a continuous aggregate is a specialized hypertable. -
Add a policy to convert chunks to the columnstore at a specific time interval:
Create a columnstore_policy that automatically converts chunks in a hypertable to
the columnstore at a specific time interval. For example:
-
Use
-
Hypertables:
Use
-
Check the columnstore policy
-
View your data space saving:
When you convert data to the columnstore, as well as being optimized for analytics, it is compressed by more than
90%. This helps you save on storage costs and keeps your queries operating at lightning speed. To see the amount of
space saved:
You see something like:
-
View the policies that you set or the policies that already exist:
See
timescaledb_information.jobs.
-
View your data space saving:
When you convert data to the columnstore, as well as being optimized for analytics, it is compressed by more than
90%. This helps you save on storage costs and keeps your queries operating at lightning speed. To see the amount of
space saved:
-
Pause a columnstore policy
See
alter_job. -
Restart a columnstore policy
See
alter_job. -
Remove a columnstore policy
See
remove_columnstore_policy. -
Disable columnstore
If your table has chunks in the columnstore, you have to
convert the chunks back to the rowstore before you disable the columnstore.
See
ALTER TABLE.