hypertable 控制api
分区分块
.add_dimension .attach_tablespace .create_hypertable .drop_chunks
SELECT create_hypertable('table', 'ts', chunk_time_interval => interval '30 weeks');//hypertable分片分区按时间30w
SELECT add_dimension('table', 'uid', number_partitions => 30);
SELECT attach_tablespace('disk1', 'table');
SELECT attach_tablespace('disk2', 'conditions', if_not_attached => true);
SELECT drop_chunks(interval '3 months', 'conditions');
分析类函数Analytics
方便进行时序分析的一些函数,比如first 、last、time_bucket
SELECT device_id, first(temp, time)
FROM metrics
GROUP BY device_id;
SELECT device_id, time_bucket('5 minutes', time) as interval, last(temp, time)
FROM metrics WHERE time > now () - interval '1 day'
GROUP BY device_id, interval
ORDER BY interval DESC;
工具类
chunk_relation_size
chunk_relation_size_pretty
hypertable_relation_size
hypertable_relation_size_pretty
show_tablespaces