TimescaleDB 快速上手

快速使用TimescaleDB的基本功能

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

  1. CREATE TABLE stocks_real_time
  2. (
  3. time TIMESTAMPTZ NOT NULL,
  4. symbol TEXT NOT NULL,
  5. price DOUBLE PRECISION NULL,
  6. day_volume INT NULL
  7. );
  8. SELECT create_hypertable('stocks_real_time', 'time');
  9. CREATE INDEX ix_symbol_time ON stocks_real_time (symbol, time DESC);
  1. TABLE timescaledb_information.hypertables;
  2. TABLE timescaledb_information.chunks;
  1. SELECT add_retention_policy('conditions', INTERVAL '24 hours');
  2. SELECT remove_retention_policy('conditions');
  3. SELECT j.hypertable_name,
  4. j.job_id,
  5. config,
  6. schedule_interval,
  7. job_status,
  8. last_run_status,
  9. last_run_started_at,
  10. js.next_start,
  11. total_runs,
  12. total_successes,
  13. total_failures
  14. FROM timescaledb_information.jobs j
  15. JOIN timescaledb_information.job_stats js
  16. ON j.job_id = js.job_id
  17. WHERE j.proc_name = 'policy_retention';

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