This commit is contained in:
Dusan Vojacek
2026-03-20 14:30:03 +01:00
parent 2cc5ccfda7
commit 897b95f728
48 changed files with 4034 additions and 842 deletions

View File

@@ -73,8 +73,34 @@ SELECT create_hypertable(
-- ============================================================
-- Kompresní politiky pro staré chunky
-- Telemetrie starší 30 dní komprimovat (čtení stačí)
-- Nutné nejdřív zapnout kompresi na hypertable (TimescaleDB 2.x+ / Tiger Data),
-- jinak add_compression_policy hlásí chybu o columnstore / compression.
-- ============================================================
ALTER TABLE ems.telemetry_inverter SET (
timescaledb.compress,
timescaledb.compress_orderby = 'measured_at DESC',
timescaledb.compress_segmentby = 'site_id, inverter_id'
);
ALTER TABLE ems.telemetry_ev_charger SET (
timescaledb.compress,
timescaledb.compress_orderby = 'measured_at DESC',
timescaledb.compress_segmentby = 'site_id, charger_id, connector_id'
);
ALTER TABLE ems.telemetry_heat_pump SET (
timescaledb.compress,
timescaledb.compress_orderby = 'measured_at DESC',
timescaledb.compress_segmentby = 'site_id, heat_pump_id'
);
ALTER TABLE ems.market_interval_price SET (
timescaledb.compress,
timescaledb.compress_orderby = 'interval_start DESC',
timescaledb.compress_segmentby = 'market_source'
);
SELECT add_compression_policy('ems.telemetry_inverter', INTERVAL '30 days', if_not_exists => TRUE);
SELECT add_compression_policy('ems.telemetry_ev_charger', INTERVAL '30 days', if_not_exists => TRUE);
SELECT add_compression_policy('ems.telemetry_heat_pump', INTERVAL '30 days', if_not_exists => TRUE);