Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning for poor compression ratio #7756

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/pr_7756
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implements: #7756 Add warning for poor compression ratio
11 changes: 11 additions & 0 deletions src/guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ TSDLLEXPORT bool ts_guc_default_hypercore_use_access_method = false;
bool ts_guc_enable_chunk_skipping = false;
TSDLLEXPORT bool ts_guc_enable_segmentwise_recompression = true;
TSDLLEXPORT bool ts_guc_enable_bool_compression = false;
TSDLLEXPORT bool ts_guc_enable_compression_ratio_warnings = true;

/* Enable of disable columnar scans for columnar-oriented storage engines. If
* disabled, regular sequence scans will be used instead. */
Expand Down Expand Up @@ -761,6 +762,16 @@ _guc_init(void)
NULL,
NULL);

DefineCustomBoolVariable(MAKE_EXTOPTION("enable_compression_ratio_warnings"),
"Enable warnings for poor compression ratio",
"Enable warnings for poor compression ratio",
&ts_guc_enable_compression_ratio_warnings,
true,
PGC_USERSET,
0,
NULL,
NULL,
NULL);
/*
* Define the limit on number of invalidation-based refreshes we allow per
* refresh call. If this limit is exceeded, fall back to a single refresh that
Expand Down
1 change: 1 addition & 0 deletions src/guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extern TSDLLEXPORT bool ts_guc_enable_merge_on_cagg_refresh;
extern bool ts_guc_enable_chunk_skipping;
extern TSDLLEXPORT bool ts_guc_enable_segmentwise_recompression;
extern TSDLLEXPORT bool ts_guc_enable_bool_compression;
extern TSDLLEXPORT bool ts_guc_enable_compression_ratio_warnings;

#ifdef USE_TELEMETRY
typedef enum TelemetryLevel
Expand Down
1 change: 1 addition & 0 deletions test/postgresql.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ extra_float_digits=0
@TELEMETRY_DEFAULT_SETTING@

timescaledb.license='apache'
timescaledb.enable_compression_ratio_warnings=false
11 changes: 11 additions & 0 deletions tsl/src/compression/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,17 @@ compress_chunk_impl(Oid hypertable_relid, Oid chunk_relid)
*/
ts_chunk_constraints_create(cxt.compress_ht, compress_ht_chunk);
ts_trigger_create_all_on_chunk(compress_ht_chunk);

/* Detect and emit warning if poor compression ratio is found */
float compression_ratio = ((float) before_size.total_size / after_size.total_size);
float POOR_COMPRESSION_THRESHOLD = 1.0;
elog(ts_guc_enable_compression_ratio_warnings &&
compression_ratio < POOR_COMPRESSION_THRESHOLD ?
WARNING :
DEBUG1,
"size before compression: %ld bytes, size after compression: %ld bytes",
before_size.total_size,
after_size.total_size);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions tsl/test/postgresql.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ log_statement='all'
# It is necessary to have at least 2 more workers than `max_worker_processes`
# in order to test failures starting bgworkers.
timescaledb.max_background_workers=26
timescaledb.enable_compression_ratio_warnings=false
Loading