summaryrefslogtreecommitdiffstats
path: root/database/rrddim.c
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-05-18 20:10:26 +0300
committerGitHub <noreply@github.com>2022-05-18 20:10:26 +0300
commit77b30d25d8d4a82272b4e010dd674bd69db0c929 (patch)
tree0d4a03f3ddeeb39eb2146677eeea3bbef73ee36d /database/rrddim.c
parent8f01f76d59c4c55e030c68198c4ae7131099b4d4 (diff)
Optimize the dimensions option store to the metadata database (#12952)
* Add a flag to "cache" the latest hidden status written in the database * rrddim hide and unhide will check "cached" state, update the database if needed and set the cache flag accordingly * Check the dimension option and only do the database update if the cached state is different
Diffstat (limited to 'database/rrddim.c')
-rw-r--r--database/rrddim.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/database/rrddim.c b/database/rrddim.c
index 31982c38fe..e488d8b0b6 100644
--- a/database/rrddim.c
+++ b/database/rrddim.c
@@ -472,9 +472,11 @@ int rrddim_hide(RRDSET *st, const char *id) {
error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, st->name, st->id, host->hostname);
return 1;
}
- (void) sql_set_dimension_option(&rd->state->metric_uuid, "hidden");
+ if (!rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN))
+ (void)sql_set_dimension_option(&rd->state->metric_uuid, "hidden");
rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
+ rrddim_flag_set(rd, RRDDIM_FLAG_META_HIDDEN);
return 0;
}
@@ -487,9 +489,11 @@ int rrddim_unhide(RRDSET *st, const char *id) {
error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, st->name, st->id, host->hostname);
return 1;
}
- (void) sql_set_dimension_option(&rd->state->metric_uuid, NULL);
+ if (rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN))
+ (void)sql_set_dimension_option(&rd->state->metric_uuid, NULL);
rrddim_flag_clear(rd, RRDDIM_FLAG_HIDDEN);
+ rrddim_flag_clear(rd, RRDDIM_FLAG_META_HIDDEN);
return 0;
}