feat(db): compress aggregates, bound daily retention and disable telemetry
The hourly and daily aggregates are compressed after 30 and 180 days and the daily aggregate is no longer kept forever. TimescaleDB telemetry is turned off for the database, as self-hosted installations must not report to third parties. Refs #63 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
7a085e22d0
commit
97229b91d1
1 file changed
+33
@@ -0,0 +1,33 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- TimescaleDB reports usage to its vendor by default. Self-hosted
|
||||||
|
-- installations must not phone home, so it is switched off for this
|
||||||
|
-- database; the setting applies to new connections and background jobs.
|
||||||
|
-- +goose StatementBegin
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
EXECUTE format('ALTER DATABASE %I SET timescaledb.telemetry_level = off', current_database());
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- Aggregates are compressed once they are past their refresh window.
|
||||||
|
ALTER MATERIALIZED VIEW check_results_1h SET (timescaledb.compress = true);
|
||||||
|
SELECT add_compression_policy('check_results_1h', compress_after => INTERVAL '30 days');
|
||||||
|
ALTER MATERIALIZED VIEW check_results_1d SET (timescaledb.compress = true);
|
||||||
|
SELECT add_compression_policy('check_results_1d', compress_after => INTERVAL '180 days');
|
||||||
|
|
||||||
|
-- The daily aggregate was kept forever, including data of deleted monitors.
|
||||||
|
-- The API adjusts all retention periods to its configuration at start.
|
||||||
|
SELECT add_retention_policy('check_results_1d', INTERVAL '1095 days');
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
SELECT remove_retention_policy('check_results_1d', if_exists => true);
|
||||||
|
SELECT remove_compression_policy('check_results_1d', if_exists => true);
|
||||||
|
SELECT remove_compression_policy('check_results_1h', if_exists => true);
|
||||||
|
-- +goose StatementBegin
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
EXECUTE format('ALTER DATABASE %I RESET timescaledb.telemetry_level', current_database());
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
-- +goose StatementEnd
|
||||||
Reference in new issue
Block a user