TimescaleDB 快速上手

快速使用TimescaleDB的基本功能

https://docs.timescale.com/getting-started/latest/create-hypertable/#hypertables-and-chunks

CREATE TABLE stocks_real_time
(
    time       TIMESTAMPTZ      NOT NULL,
    symbol     TEXT             NOT NULL,
    price      DOUBLE PRECISION NULL,
    day_volume INT              NULL
);

SELECT create_hypertable('stocks_real_time', 'time');
CREATE INDEX ix_symbol_time ON stocks_real_time (symbol, time DESC);
TABLE timescaledb_information.hypertables;
TABLE timescaledb_information.chunks;
SELECT add_retention_policy('conditions', INTERVAL '24 hours');
SELECT remove_retention_policy('conditions');

SELECT j.hypertable_name,
       j.job_id,
       config,
       schedule_interval,
       job_status,
       last_run_status,
       last_run_started_at,
       js.next_start,
       total_runs,
       total_successes,
       total_failures
FROM timescaledb_information.jobs j
         JOIN timescaledb_information.job_stats js
              ON j.job_id = js.job_id
WHERE j.proc_name = 'policy_retention';

最后修改 2022-07-12: add new article pg-is-best (fae5568)