I have noticed thaht when I remove ((reports.kind = ‘apply’ AND
reports.status = ‘failed’) part from the query, the query is very
quick.
mysql> show index from reports from dashboard;
+---------+------------+----------------------------------------------
+--------------+-------------+-----------+-------------+----------
+--------+------+------------+---------+
| Table | Non_unique | Key_name
| Seq_in_index | Column_name | Collation | Cardinality | Sub_part |
Packed | Null | Index_type | Comment |
+---------+------------+----------------------------------------------
+--------------+-------------+-----------+-------------+----------
+--------+------+------------+---------+
| reports | 0 | PRIMARY
| 1 | id | A | 112252 | NULL |
NULL | | BTREE | |
| reports | 1 | index_reports_on_node_id
| 1 | node_id | A | 652 | NULL |
NULL | YES | BTREE | |
| reports | 1 | index_reports_on_time_and_node_id_and_status
| 1 | time | A | 112252 | NULL |
NULL | YES | BTREE | |
| reports | 1 | index_reports_on_time_and_node_id_and_status
| 2 | node_id | A | 112252 | NULL |
NULL | YES | BTREE | |
| reports | 1 | index_reports_on_time_and_node_id_and_status
| 3 | status | A | 112252 | NULL |
NULL | YES | BTREE | |
+---------+------------+----------------------------------------------
+--------------+-------------+-----------+-------------+----------
+--------+------+------------+---------+
5 rows in set (0.01 sec)