Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Timescaledb

Romain edited this page Jun 30, 2019 · 5 revisions

Large tables are maintained with timescaledb extension:

  • Create model and migrate as usual with django manage.py
  • Then copy the structure of the table but not the indexes:
CREATE TABLE ihr_delay_alarms_new (LIKE ihr_delay_alarms INCLUDING DEFAULTS INCLUDING CONSTRAINTS EXCLUDING INDEXES);
  • Set the proper tablespace:
ALTER TABLE ihr_delay_alarms_new SET TABLESPACE nas0_slow_tablespace ;
  • Create the hypertable and insert data in it:
SELECT create_hypertable('ihr_delay_alarms_new', 'timebin', chunk_time_interval => interval '7 day');
INSERT INTO ihr_delay_alarms_new  SELECT * FROM ihr_delay_alarms;
  • Create necessary indexes:
CREATE INDEX ON ihr_delay_alarms_new (asn_id, timebin DESC);

Clone this wiki locally