Skip to content

Instantly share code, notes, and snippets.

@Nurlan199206
Last active March 27, 2019 08:42
Show Gist options
  • Save Nurlan199206/27b66221e6f7d09f0b328bbb251f39e1 to your computer and use it in GitHub Desktop.
Save Nurlan199206/27b66221e6f7d09f0b328bbb251f39e1 to your computer and use it in GitHub Desktop.
#keep 1 week of history and 3 months of trends
DELETE FROM history_uint where age(to_timestamp(history_uint.clock)) > interval '1 days';
delete FROM alerts where age(to_timestamp(alerts.clock)) > interval '7 days';
delete FROM acknowledges where age(to_timestamp(acknowledges.clock)) > interval '7 days';
delete FROM events where age(to_timestamp(events.clock)) > interval '7 days';
delete FROM history where age(to_timestamp(history.clock)) > interval '7 days';
delete FROM history_uint where age(to_timestamp(history_uint.clock)) > interval '7 days' ;
delete FROM history_str where age(to_timestamp(history_str.clock)) > interval '7 days' ;
delete FROM history_text where age(to_timestamp(history_text.clock)) > interval '7 days' ;
delete FROM history_log where age(to_timestamp(history_log.clock)) > interval '7 days' ;
delete FROM trends where age(to_timestamp(trends.clock)) > interval '90 days';
delete FROM trends_uint where age(to_timestamp(trends_uint.clock)) > interval '90 days' ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment