we opened the slow_sql.log and we found this below:
# Time: 2019-07-24T12:01:55.966733Z
# User@Host: librenms[librenms] @ [10.1.0.213] Id: 226576
# Query_time: 29.131667 Lock_time: 0.000035 Rows_sent: 1 Rows_examined: 109419476
SET timestamp=1563969715;
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
= 26));
# Time: 2019-07-24T12:02:22.652229Z
# User@Host: librenms[librenms] @ [10.1.0.213] Id: 226850
# Query_time: 29.477817 Lock_time: 0.000033 Rows_sent: 1 Rows_examined: 109419476
SET timestamp=1563969742;
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
= 26));
1、what’s this sql for?
2、How do we will solve this problem,by Index or something else ?