I am using MySQL as a data source in grafana dashboard and using MySQL query with joins and group by clause.
select stu.name,(count(case when r.status='PASS' Then 'Pass' end) / count(*)) * 100 as pass_percentage from student stu inner join result r on stu.student_id=r.student_id inner join subjects sub on sub.subject_id=stu.subject_id and sub.subject_name is not null group by stu.id;
This query takes less than 3 seconds in MySQL workbench but taking more time like 5 to 7 minutes on grafana dashboard.
MySQL Version - 8.0.20
Grafana Version - 7.3.1
How can I improve the performance of the MySQL query.