Hello,
I have an issue with grafana and our mysql server . I have this query whose taking more than 30 second to be execute and my cpu is too high.
I don’t know why and who make this query :
SELECT (SELECT COUNT(*) FROM `user`) AS users,(SELECT COUNT(*) FROM `org`) AS orgs,(SELECT COUNT(*) FROM `dashboard`) AS dashboards,(SELECT COUNT(*) FROM `data_source`) AS datasources,(SELECT COUNT(*) FROM `star`) AS stars,(SELECT COUNT(*) FROM `playlist`) AS playlists,(SELECT COUNT(*) FROM `alert`) AS alerts,(SELECT COUNT(*) FROM `user` where last_seen_at > ?) AS active_users,(SELECT COUNT(id) FROM `dashboard` where is_folder = ?) AS folders,(
SELECT COUNT(acl.id)
FROM `dashboard_acl` as acl
inner join `dashboard` as d
on d.id = acl.dashboard_id
WHERE d.is_folder = ?
) AS dashboard_permissions,(
SELECT COUNT(acl.id)
FROM `dashboard_acl` as acl
inner join `dashboard` as d
on d.id = acl.dashboard_id
WHERE d.is_folder = ?
) AS folder_permissions,(SELECT COUNT(id) FROM `dashboard_provisioning`) AS provisioned_dashboards,(SELECT COUNT(id) FROM `dashboard_snapshot`) AS snapshots,(SELECT COUNT(id) FROM `team`) AS teams,(SELECT COUNT(id) FROM `user_auth_token`) AS auth_tokens,
(
SELECT COUNT(*)
FROM `user` as u
WHERE
(SELECT COUNT(*)
FROM org_user
WHERE org_user.user_id=u.id
AND org_user.role='Viewer')>0
) as viewers,
(
SELECT COUNT(*)
FROM `user` as u
WHERE
(SELECT COUNT(*)
FROM org_user
WHERE org_user.user_id=u.id
AND org_user.role='Viewer')>0
AND u.last_seen_at>?
) as active_viewers,
(
SELECT COUNT(*)
FROM `user` as u
WHERE
(SELECT COUNT(*)
FROM org_user
WHERE org_user.user_id=u.id
AND org_user.role='Editor')>0
) as editors,
(
SELECT COUNT(*)
FROM `user` as u
WHERE
(SELECT COUNT(*)
FROM org_user
WHERE org_user.user_id=u.id
AND org_user.role='Editor')>0
AND u.last_seen_at>?
) as active_editors,
(
SELECT COUNT(*)
FROM `user` as u
WHERE
(SELECT COUNT(*)
FROM org_user
WHERE org_user.user_id=u.id
AND org_user.role='Admin')>0
) as admins,
(
SELECT COUNT(*)
FROM `user` as u
WHERE
(SELECT COUNT(*)
FROM org_user
WHERE org_user.user_id=u.id
AND org_user.role='Admin')>0
AND u.last_seen_at>?
) as active_admins
Do you know How can I stop this query and why grafana is doing this query everytime.
Best regards