From 473671a90194329ff0fc719a027c8f5df7cebb1c Mon Sep 17 00:00:00 2001 From: Lana Brindley Date: Thu, 24 Feb 2022 00:04:37 +1000 Subject: [PATCH] Revert "Revert "Doc updates for compression on continuous aggregate feature"" (#773) * Revert "Revert "Doc changes for compression on continuous aggregates feature (#666)" (#730)" This reverts commit ebb417c1d581be8dbb5e81867813d9d059e8e291. * Update timescaledb/how-to-guides/continuous-aggregates/compression-on-continuous-aggregates.md Co-authored-by: Ryan Booz * Update api/add_compression_policy.md Co-authored-by: Nuno Santos Co-authored-by: Ryan Booz Co-authored-by: Jacob Prall Co-authored-by: Nuno Santos --- api/add_compression_policy.md | 30 ++++++--- api/alter_materialized_view.md | 17 ++++- api/continuous_aggregates.md | 6 +- api/remove_compression_policy.md | 12 ++-- .../compression-on-continuous-aggregates.md | 63 +++++++++++++++++++ .../continuous-aggregates/index.md | 2 + .../continuous-aggregates/troubleshooting.md | 38 ++++++----- 7 files changed, 136 insertions(+), 32 deletions(-) create mode 100644 timescaledb/how-to-guides/continuous-aggregates/compression-on-continuous-aggregates.md diff --git a/api/add_compression_policy.md b/api/add_compression_policy.md index 85f42554bb52..4c48d078ef67 100644 --- a/api/add_compression_policy.md +++ b/api/add_compression_policy.md @@ -2,18 +2,21 @@ Allows you to set a policy by which the system compresses a chunk automatically in the background after it reaches a given age. -Note that compression policies can only be created on hypertables that already -have compression enabled, e.g., via the [`ALTER TABLE`][compression_alter-table] command -to set `timescaledb.compress` and other configuration parameters. +Note that compression policies can only be created on hypertables or continuous +aggregates that already have compression enabled. Use the [`ALTER TABLE`][compression_alter-table] command +to set `timescaledb.compress` and other configuration parameters for hypertables. +Use [`ALTER MATERIALIZED VIEW`][compression_continuous-aggregate] command to +enable compression on continuous aggregates -### Required Arguments +### Required arguments |Name|Type|Description| |---|---|---| -| `hypertable` |REGCLASS| Name of the hypertable| +| `hypertable` |REGCLASS| Name of the hypertable or continuous aggregate| | `compress_after` | INTERVAL or INTEGER | The age after which the policy job compresses chunks| -The `compress_after` parameter should be specified differently depending on the type of the time column of the hypertable: +The `compress_after` parameter should be specified differently depending +on the type of the time column of the hypertable or continuous aggregate: - For hypertables with TIMESTAMP, TIMESTAMPTZ, and DATE time columns: the time interval should be an INTERVAL type. - For hypertables with integer-based timestamps: the time interval should be an integer type (this requires the [integer_now_func][set_integer_now_func] to be set). @@ -24,7 +27,14 @@ the [integer_now_func][set_integer_now_func] to be set). |---|---|---| | `if_not_exists` | BOOLEAN | Setting to true causes the command to fail with a warning instead of an error if a compression policy already exists on the hypertable. Defaults to false.| -### Sample Usage + +Compression policies on continuous aggregates should be set up so that they do +not overlap with refresh policies on continuous aggregates. This is due to a +current TimescaleDB limitation that prevents refresh of compressed regions of +continuous aggregates. + + +### Sample usage Add a policy to compress chunks older than 60 days on the 'cpu' hypertable. ``` sql @@ -37,6 +47,12 @@ Add a compress chunks policy to a hypertable with an integer-based time column: SELECT add_compression_policy('table_with_bigint_time', BIGINT '600000'); ``` +Add a policy to compress chunks of a continuous aggregate called `cpu_weekly`, that are +older than eight weeks: +``` sql +SELECT add_compression_policy('cpu_weekly', INTERVAL '8 weeks'); +``` [compression_alter-table]: /api/:currentVersion:/compression/alter_table_compression/ +[compression_continuous-aggregate]: /api/:currentVersion:/continuous-aggregates/alter_materialized_view/ [set_integer_now_func]: /hypertable/set_integer_now_func diff --git a/api/alter_materialized_view.md b/api/alter_materialized_view.md index 63831afe51ea..0d0dc5be763a 100644 --- a/api/alter_materialized_view.md +++ b/api/alter_materialized_view.md @@ -18,8 +18,13 @@ ALTER MATERIALIZED VIEW SET ( timescaledb.