MariaDB [zabbix]> analyze select distinct i2.key_ from items i join item_discovery id on id.itemid=i.itemid join items i2 on id.parent_itemid=i2.itemid join functions f on i.itemid=f.itemid and f.triggerid=13272 where i.flags=2; +------+-------------+-------+--------+-----------------------------------+------------------+---------+----------------------------------+------+-----------+----------+------------+------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra | +------+-------------+-------+--------+-----------------------------------+------------------+---------+----------------------------------+------+-----------+----------+------------+------------------------------------+ | 1 | SIMPLE | i | ALL | PRIMARY | NULL | NULL | NULL | 1 | 188622.00 | 100.00 | 13.01 | Using where; Using temporary | | 1 | SIMPLE | i2 | ALL | PRIMARY | NULL | NULL | NULL | 1 | 188622.00 | 100.00 | 100.00 | Using join buffer (flat, BNL join) | | 1 | SIMPLE | f | ref | functions_1,functions_2 | functions_1 | 8 | const | 1 | 1.00 | 100.00 | 0.00 | Using where; Distinct | | 1 | SIMPLE | id | eq_ref | item_discovery_1,item_discovery_2 | item_discovery_1 | 16 | zabbix.i.itemid,zabbix.i2.itemid | 1 | 0.00 | 100.00 | 100.00 | Using index; Distinct | +------+-------------+-------+--------+-----------------------------------+------------------+---------+----------------------------------+------+-----------+----------+------------+------------------------------------+ 4 rows in set (10 hours 22 min 12.916 sec)