add_columnstore_policy() replaces add_compression_policy(), deprecated in 2.18.0.
Create a job that automatically moves s in a to the after a
specific time interval.
Continuous aggregates:You first call ALTER MATERIALIZED VIEW to enable the on a , then create the job that converts
your data to the with a call to add_columnstore_policy.
Hypertables:When you create a using CREATE TABLE … WITH …, the default partitioning
column is automatically the first column with a timestamp data type. Also, creates a
columnstore policy that automatically converts your data to the , after an
interval equal to the value of the chunk_interval, defined through compress_after in the
policy. This columnar format enables fast scanning and
aggregation, optimizing performance for analytical workloads while also saving significant storage space. In the
conversion, s are compressed by up to 98%, and organized for efficient, large-scale queries.You can customize this policy later using alter_job. However, to change after or
created_before, the compression settings, or the the policy is acting on, you must
remove the columnstore policy and add a new one.You can also manually convert s in a to the .
When is enabled, bloom filters are enabled by default, and every new has a bloom
index.
Bloom indexes are not retrofitted, existing s need to be fully recompressed to have the bloom indexes present. If
you converted s to using v2.19.3 or below, to enable bloom filters on that data you have
to convert those s to the , then convert them back to the .To view the policies that you set or the policies that already exist, see informational views.A policy is applied on a per- basis. If you remove an existing policy and then add a new one, the
new
policy applies only to the s that have not yet been converted to . The existing s in the
remain unchanged. This means that s with different settings can co-exist in the same
.
CREATE TABLE crypto_ticks ( "time" TIMESTAMPTZ, symbol TEXT, price DOUBLE PRECISION, day_volume NUMERIC) WITH ( tsdb.hypertable, tsdb.segmentby='symbol', tsdb.orderby='time DESC');
For v2.23.0 and higher, the table is automatically partitioned on the first column
in the table with a timestamp data type. If multiple columns are suitable candidates as a partitioning column,
throws an error and asks for an explicit definition. For earlier versions, set partition_column to a
time column.If you are self-hosting v2.20.0 to v2.22.1, to convert your
data to the after a specific time interval, you have to call add_columnstore_policy after you call
CREATE TABLEIf you are self-hosting v2.19.3 and below, create a relational table,
then convert it using create_hypertable. You then enable with a call
to ALTER TABLE.
Control the time your policy runs:When you use a policy with a fixed schedule, uses the initial_start time to compute the
next start time. When finishes executing a policy, it picks the next available time on the
schedule,
skipping any candidate start times that have already passed.When you set the next_start time, it only changes the start time of the next immediate execution. It does not
change the computation of the next scheduled execution after that next execution. To change the schedule so a
policy starts at a specific time, you need to set initial_start. To change the next immediate
execution, you need to set next_start. For example, to modify a policy to execute on a fixed schedule 15 minutes
past the hour, and every
hour, you need to set both initial_start and next_start using alter_job: