Hi,
The following query is taking 3 mins to execute and table has 30 million rows…
SELECT host_ip “Users”, SUM(events) “Connections”, TRUNCATE((SUM(bytes) * 1.0000), 2) “Cost (INR)”,
SUM(bytes) “MBytes” FROM vp_top_summary
WHERE firewall_report_id IN (1118,1142) AND host_id = -1 GROUP BY host_ip ORDER BY “MBytes” DESC LIMIT 20;
index information is as follows
mysql> show index from vp_top_summary;
±---------------±-----------±---------±-------------±-- -----------------±-
---------±------------±---------±-------±-----±-------- —±--------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | C
ollation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
±---------------±-----------±---------±-------------±-- -----------------±-
---------±------------±---------±-------±-----±-------- —±--------+
| vp_top_summary | 1 | vpts_ihf | 1 | host_ip | A
| 52290909 | NULL | NULL | YES | BTREE | |
| vp_top_summary | 1 | vpts_ihf | 2 | host_name | A
| 52290909 | NULL | NULL | YES | BTREE | |
| vp_top_summary | 1 | vpts_ihf | 3 | firewall_report_id | A
| 52290909 | NULL | NULL | YES | BTREE | |
| vp_top_summary | 1 | vpts_f | 1 | firewall_report_id | A
| 17 | NULL | NULL | YES | BTREE | |
| vp_top_summary | 1 | vpts_i | 1 | id | A
| 52290909 | NULL | NULL | | BTREE | |
±---------------±-----------±---------±-------------±-- -----------------±-
---------±------------±---------±-------±-----±-------- —±--------+
5 rows in set (0.45 sec)
any suggestions or ideas will be appreciated…
thanks in advance…