Missing MySQL index for table notifications_attribs?

Is LibreNMS perhaps missing an index for the notifications_attribs table?

I noticed the webinterface was getting realllly slow (each click 5+ seconds) and had a look, seems the database was busy only counting notifications:

select count(*) as aggregate from `notifications` left join `notifications_attribs` on `notifications_attribs`.`notifications_id` = `notifications`.`notifications_id` where (`notifications_attribs`.`key` = 'sticky' and `notifications_attribs`.`value` = 1) or (not exists (select 1 from `notifications_attribs` where notifications.notifications_id = notifications_attribs.notifications_id and `notifications_attribs`.`user_id` = 123));

Query_time: 6.830290 (seconds!)
Lock_time: 0.000043
Rows_sent: 1
Rows_examined: 23752917 (!!!)

CREATE INDEX `notifications_attribs_user_idx` ON `notifications_attribs` (`notifications_id`,`user_id`);

would solve it (for me), but then of course validate.php complains about “Database: extra index (notifications_attribs/notifications_attribs_user_idx)” – so that’s why I’m here now reporting this issue, hoping to get it resolved upstream instead :slight_smile:

more details: https://pastebin.com/6uhWqUZ4