Skip to content

Commit

Permalink
Remove limitation of compression policy for continuous aggregates
Browse files Browse the repository at this point in the history
Before compressed chunks were mutable, adding a compression policy
to a continuous aggregate that could include portions of the refrsh
window were blocked. When a continuous aggregate is refreshed, the
underlying chunks needed to allow DELETEs and INSERTs, so they
could not be compressed. Now, compressed chunks allow both operations
and there is no longer a need to prevent the refresh window and
compression window from overlapping.
  • Loading branch information
RobAtticus committed Feb 4, 2025
1 parent 1c1743d commit 6ca7568
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 37 deletions.
1 change: 1 addition & 0 deletions .unreleased/pr_7656
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implements: #7656 Remove limitation of compression policy for continuous aggregates
15 changes: 0 additions & 15 deletions tsl/src/bgw_policy/compression_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,21 +338,6 @@ policy_compression_add_internal(Oid user_rel_oid, Datum compress_after_datum,
POL_COMPRESSION_CONF_KEY_COMPRESS_AFTER,
format_type_be(compress_after_type))));
}
/*
* If this is a compression policy for a cagg, verify that
* compress_after > refresh_start of cagg policy. We do not want
* to compress regions that can be refreshed by the cagg policy.
*/
if (is_cagg && !policy_refresh_cagg_refresh_start_lt(hypertable->fd.id,
compress_after_type,
compress_after_datum))
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("compress_after value for compression policy should be greater than the "
"start of the refresh window of continuous aggregate policy for %s",
get_rel_name(user_rel_oid))));
}

JsonbValue *result = pushJsonbValue(&parse_state, WJB_END_OBJECT, NULL);
Jsonb *config = JsonbValueToJsonb(result);
Expand Down
6 changes: 0 additions & 6 deletions tsl/test/expected/cagg_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,8 @@ ALTER MATERIALIZED VIEW i2980_cagg SET ( timescaledb.compress );
NOTICE: defaulting compress_orderby to time_bucket
WARNING: there was some uncertainty picking the default segment by for the hypertable: You do not have any indexes on columns that can be used for segment_by and thus we are not using segment_by for compression. Please make sure you are not missing any indexes
NOTICE: default segment by for hypertable "_materialized_hypertable_13" is set to ""
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for i2980_cagg
SELECT add_continuous_aggregate_policy('i2980_cagg2', '10 day'::interval, '6 day'::interval);
ERROR: function add_continuous_aggregate_policy(unknown, interval, interval) does not exist at character 8
SELECT add_compression_policy('i2980_cagg2', '3 day'::interval);
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for i2980_cagg2
SELECT add_compression_policy('i2980_cagg2', '1 day'::interval);
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for i2980_cagg2
SELECT add_compression_policy('i2980_cagg2', '3'::integer);
ERROR: unsupported compress_after argument type, expected type : interval
SELECT add_compression_policy('i2980_cagg2', 13::integer);
Expand Down
8 changes: 0 additions & 8 deletions tsl/test/expected/cagg_policy.out
Original file line number Diff line number Diff line change
Expand Up @@ -1158,14 +1158,6 @@ ALTER MATERIALIZED VIEW mat_smallint SET (timescaledb.compress);
NOTICE: defaulting compress_orderby to a
WARNING: there was some uncertainty picking the default segment by for the hypertable: You do not have any indexes on columns that can be used for segment_by and thus we are not using segment_by for compression. Please make sure you are not missing any indexes
NOTICE: default segment by for hypertable "_materialized_hypertable_11" is set to ""
\set ON_ERROR_STOP 0
SELECT add_compression_policy('mat_smallint', 0::smallint);
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for mat_smallint
SELECT add_compression_policy('mat_smallint', -4::smallint);
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for mat_smallint
SELECT add_compression_policy('mat_bigint', 0::bigint);
ERROR: compress_after value for compression policy should be greater than the start of the refresh window of continuous aggregate policy for mat_bigint
\set ON_ERROR_STOP 1
SELECT add_compression_policy('mat_smallint', 5::smallint);
add_compression_policy
------------------------
Expand Down
3 changes: 0 additions & 3 deletions tsl/test/sql/cagg_errors.sql
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,8 @@ ALTER MATERIALIZED VIEW i2980_cagg2 SET ( timescaledb.compress, timescaledb.comp
select add_continuous_aggregate_policy('i2980_cagg2', interval '10 day', interval '2 day' ,'4h') AS job_id ;
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);
ALTER MATERIALIZED VIEW i2980_cagg SET ( timescaledb.compress );
SELECT add_compression_policy('i2980_cagg', '8 day'::interval);

SELECT add_continuous_aggregate_policy('i2980_cagg2', '10 day'::interval, '6 day'::interval);
SELECT add_compression_policy('i2980_cagg2', '3 day'::interval);
SELECT add_compression_policy('i2980_cagg2', '1 day'::interval);
SELECT add_compression_policy('i2980_cagg2', '3'::integer);
SELECT add_compression_policy('i2980_cagg2', 13::integer);

Expand Down
5 changes: 0 additions & 5 deletions tsl/test/sql/cagg_policy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,6 @@ SELECT * FROM mat_bigint WHERE a>100 ORDER BY 1;

ALTER MATERIALIZED VIEW mat_bigint SET (timescaledb.compress);
ALTER MATERIALIZED VIEW mat_smallint SET (timescaledb.compress);
\set ON_ERROR_STOP 0
SELECT add_compression_policy('mat_smallint', 0::smallint);
SELECT add_compression_policy('mat_smallint', -4::smallint);
SELECT add_compression_policy('mat_bigint', 0::bigint);
\set ON_ERROR_STOP 1
SELECT add_compression_policy('mat_smallint', 5::smallint);
SELECT add_compression_policy('mat_bigint', 20::bigint);

Expand Down

0 comments on commit 6ca7568

Please sign in to comment.