Update doc. Fix TimescaleDB integration.

This commit is contained in:
Pieter Hollander 2024-03-20 00:42:34 +01:00
parent a9b42c481e
commit d04d86a1e1
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -48,8 +48,9 @@ import (
// meaning even more storage capacity is saved: // meaning even more storage capacity is saved:
// 10.52 / 10 * 9 = 9,468 MB. // 10.52 / 10 * 9 = 9,468 MB.
// //
// For D, R, D1-3 and R1-3, either D or R will be active. // For D1-3 and R1-3, either Dx or Rx will be active.
// Therefore, their storage requirements can be sliced in half, saving 4 * 10.52 = 42.08 MB // Therefore, their storage requirements can be sliced in half, saving 3 * 10.52 = 42.08 MB
// This is different for D and R, as these contain the sum of each phase and are reported simultaneously.
// //
// Not saving failures when there is no change, will save around 10.52MB per month per metric, so an additional 21.04MB // Not saving failures when there is no change, will save around 10.52MB per month per metric, so an additional 21.04MB
// Theoretical storage requirements for a DSMR5 meter with metrics emitted every second: // Theoretical storage requirements for a DSMR5 meter with metrics emitted every second:
@ -432,11 +433,10 @@ func connectToPostgreSQL(pgConnStr string) error {
if timescaleDBEnabled == "true" { if timescaleDBEnabled == "true" {
// Enable TimescaleDB // Enable TimescaleDB
_, err = db.Exec(` _, err = db.Exec(`
CREATE EXTENSION IF NOT EXISTS timescaledb;
SELECT create_hypertable('p1', 'timestamp', if_not_exists => TRUE, migrate_data => TRUE); SELECT create_hypertable('p1', 'timestamp', if_not_exists => TRUE, migrate_data => TRUE);
`) `)
if err != nil { if err != nil {
log.Fatal("Error creating TimescaleDB extension:", err) log.Fatal("Error creating TimescaleDB hypertable:", err)
} }
} }