set timezone='UTC'; create extension if not exists timescaledb; drop table if exists tsn_ns128 cascade; create table tsn_ns128(t ns128 not null, v int); select create_hypertable('tsn_ns128', by_range('t', 86400000000000)); select create_hypertable('tsn_ns128', by_range('t', 86400000000000, partition_func => 'ns128_part')); insert into tsn_ns128 select x::bigint::ns128, i from unnest(array[-305164800000000000,-43200000000000,0,1704067200123456789,1704175200000000000,1704261600000000000]) with ordinality u(x,i); insert into tsn_ns128 values ('-62135596800000000000',7),('253402300799999999999',8); select chunk_name, range_start_integer, range_end_integer from timescaledb_information.chunks where hypertable_name='tsn_ns128' order by 2; explain (costs off) select * from tsn_ns128 where t >= 1704153600000000000::bigint::ns128 and t < 1704240000000000000::bigint::ns128; select time_bucket(86400000000000::bigint, t) from tsn_ns128 limit 1; select time_bucket(86400000000000::bigint, ns128_part(t)) b, count(*) from tsn_ns128 group by 1 order by 1; alter table tsn_ns128 set (timescaledb.compress, timescaledb.compress_segmentby='v', timescaledb.compress_orderby='t desc'); select count(compress_chunk(c)) from show_chunks('tsn_ns128') c; select v from tsn_ns128 order by t; explain (costs off) select * from tsn_ns128 where t >= 1704153600000000000::bigint::ns128 and t < 1704240000000000000::bigint::ns128; create table tsn2_ns128(t ns128 not null, v int); select create_hypertable('tsn2_ns128', by_range('t', 86400000000000, partition_func => 'ns128_part')); insert into tsn2_ns128 select * from tsn_ns128; alter table tsn2_ns128 set (timescaledb.compress, timescaledb.compress_segmentby='t'); select count(compress_chunk(c)) from show_chunks('tsn2_ns128') c; create materialized view ca_ns128 with (timescaledb.continuous) as select time_bucket(86400000000000::bigint, ns128_part(t)) b, count(*) from tsn_ns128 group by 1; select set_integer_now_func('tsn_ns128','clock_ns'); select drop_chunks('tsn_ns128', older_than => 0::bigint); select count(*) from timescaledb_information.chunks where hypertable_name='tsn_ns128'; select add_retention_policy('tsn_ns128', drop_after => 86400000000000*365);