Skip to content

Commit

Permalink
Update query to be more efficient (librenms#15622)
Browse files Browse the repository at this point in the history
  • Loading branch information
laf committed Dec 14, 2023
1 parent 624eb5a commit 3951bbb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions includes/html/table/alertlog.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
$param[] = "%$searchPhrase%";
}

$sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id RIGHT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where";
$sql = " FROM `alert_log` AS E LEFT JOIN devices AS D ON E.device_id=D.device_id LEFT JOIN alert_rules AS R ON E.rule_id=R.id WHERE $where";

$count_sql = "SELECT COUNT(`E`.`id`) $sql";
$total = dbFetchCell($count_sql, $param);
Expand Down Expand Up @@ -92,7 +92,6 @@
$rulei = 0;
foreach (dbFetchRows($sql, $param) as $alertlog) {
$dev = device_by_id_cache($alertlog['device_id']);
logfile($alertlog['rule_id']);
$log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? AND `state` = 1 ORDER BY id DESC LIMIT 1', [$alertlog['rule_id'], $alertlog['device_id']]);
$alert_log_id = dbFetchCell('SELECT id FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', [$alertlog['rule_id'], $alertlog['device_id']]);
[$fault_detail, $max_row_length] = alert_details($log);
Expand Down

0 comments on commit 3951bbb

Please sign in to comment.