Skip to content

Commit

Permalink
Small optimization of alert queries (#16282)
Browse files Browse the repository at this point in the history
(cherry picked from commit 59a983a)
  • Loading branch information
Emmanuel Vasilakis authored and tkatsoulas committed Oct 30, 2023
1 parent 750ca8e commit f80f0fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions database/sqlite/sqlite_aclk_alert.c
Expand Up @@ -71,9 +71,9 @@ static inline bool is_event_from_alert_variable_config(uint32_t unique_id, uuid_
//decide if some events should be sent or not
#define SQL_SELECT_ALERT_BY_ID \
"SELECT hld.new_status, hl.config_hash_id, hld.unique_id FROM health_log hl, aclk_alert_%s aa, health_log_detail hld " \
"WHERE hl.host_id = @host_id AND hld.unique_id = aa.filtered_alert_unique_id " \
"WHERE hl.host_id = @host_id AND +hld.unique_id = aa.filtered_alert_unique_id " \
"AND hld.alarm_id = @alarm_id AND hl.health_log_id = hld.health_log_id " \
"ORDER BY hld.alarm_event_id DESC LIMIT 1;"
"ORDER BY hld.rowid DESC LIMIT 1;"

static bool should_send_to_cloud(RRDHOST *host, ALARM_ENTRY *ae)
{
Expand Down
2 changes: 2 additions & 0 deletions database/sqlite/sqlite_functions.c
Expand Up @@ -60,6 +60,8 @@ const char *database_config[] = {
"CREATE INDEX IF NOT EXISTS health_log_d_ind_3 ON health_log_detail (transition_id);",
"CREATE INDEX IF NOT EXISTS health_log_d_ind_5 ON health_log_detail (health_log_id, unique_id DESC);",
"CREATE INDEX IF NOT EXISTS health_log_d_ind_6 on health_log_detail (health_log_id, when_key)",
"CREATE INDEX IF NOT EXISTS health_log_d_ind_7 on health_log_detail (alarm_id);",
"CREATE INDEX IF NOT EXISTS health_log_d_ind_8 on health_log_detail (new_status, updated_by_id);",

NULL
};
Expand Down

0 comments on commit f80f0fc

Please sign in to comment.