[ZBX-21027] Zabbix 6.0 LTS slow mysql queries and 100% cpu Created: 2022 May 11 Updated: 2022 Nov 04 |
|
Status: | Confirmed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 6.0.4 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Major |
Reporter: | Jesse Caudill | Assignee: | Zabbix Development Team |
Resolution: | Unresolved | Votes: | 2 |
Labels: | MariaDB, graph, mysql, performance | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Ubuntu 20.04.3 LTS |
Attachments: |
![]() ![]() |
Description |
Steps to reproduce:
I would like to know if this was the proper fix for this? Should there be a different approach? While the massively slow queries are now resolved for the 3 worst offending tables, it appears there may be other tables that are facing simliar issues. trigger_depends and items are my persistent slow queries now in the 3-5 second range. I'm not a database expert and so I'm not sure what relevant data I should include. Please let me know what other outputs are needed. |
Comments |
Comment by Edgar Akhmetshin [ 2022 May 12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hello, Do you have ANALYZE output for the query before adding additional index? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 May 12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MariaDB [zabbix]> explain select distinct d.triggerid_down,d.triggerid_up from trigger_depends d,triggers t,hosts h,items i,functions f where t.triggerid=d.triggerid_down and t.flags<>2 and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=d.triggerid_down and h.status in (0,1);
-----
----- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 May 12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MariaDB [zabbix]> analyze select i.itemid,i.hostid,i.status,i.type,i.value_type,i.key_,i.snmp_oid,i.ipmi_sensor,i.delay,i.trapper_hosts,i.logtimefmt,i.params,ir.state,i.authtype,i.username,i.password,i.publickey,i.privatekey,i.flags,i.interfaceid,ir.lastlogsize,ir.mtime,i.history,i.trends,i.inventory_link,i.valuemapid,i.units,ir.error,i.jmx_endpoint,i.master_itemid,i.timeout,i.url,i.query_fields,i.posts,i.status_codes,i.follow_redirects,i.post_type,i.http_proxy,i.headers,i.retrieve_mode,i.request_method,i.output_format,i.ssl_cert_file,i.ssl_key_file,i.ssl_key_password,i.verify_peer,i.verify_host,i.allow_traps,i.templateid,null from items i inner join hosts h on i.hostid=h.hostid join item_rtdata ir on i.itemid=ir.itemid where h.status in (0,1) and i.flags<>2;
-----
----- MariaDB [zabbix]> analyze select distinct d.triggerid_down,d.triggerid_up from trigger_depends d,triggers t,hosts h,items i,functions f where t.triggerid=d.triggerid_down and t.flags<>2 and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=d.triggerid_down and h.status in (0,1)
-----
-----
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 May 12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I'm sorry that's all I could find from my session logs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Michael Kuhn [ 2022 May 16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Jesse Do you remember the index you added for the point below:
I have the same issue with the below query running 5 minutes select distinct d.triggerid_down,d.triggerid_up from trigger_depends d,triggers t,hosts h,items i,functions f where t.triggerid=d.triggerid_down and t.flags<>2 and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=d.triggerid_down and h.status in (0,1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 May 16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I'm sorry I don't! I had someone helping me and he did the changes via console in vsphere, there doesn't seem to be any history of what he put in that I can find. Below is the output of the 'show index' for the 3 tables if that's helpful. If there's a better command I'd be happy to run it and include the output.
MariaDB [zabbix]> show index in functions;
----------
---------- MariaDB [zabbix]> show index in graphs;
-------
------- MariaDB [zabbix]> show index in triggers;
---------
--------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Michael Kuhn [ 2022 May 16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thanks Jesse This helped a lot. I added the below and my issue went away immediately. create index function_t_i on functions(triggerid, itemid); Thanks again Michael | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 May 16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Great! I was thinking function_t_i was the index added to functions. The triggers one isn't as clear to me from the output. Right now mine is giving me fits on the item_discovery table but they're in the 5-15 second range rather than 500+, so I'm hoping I can wait for the official correction on these. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Anton Baranov [ 2022 Jun 13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I'm not sure about the correctness of the request, but in my case the problem was solved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Vladislavs Sokurenko [ 2022 Jul 13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Please check if it's same issue as in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 Jul 13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
yes looks similar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Nathan [ 2022 Aug 03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hello, Did you find something on this query to improve it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Jesse Caudill [ 2022 Aug 03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
My issue and an associated ticket are apparently fixed in pre-6.0.7rc1. I believe its fixed by changing the parameters of the query rather than modifying the database.
If you are having issues I would recommend these steps: 2) Get an "analyze" output of your slow query. Sometimes the "describe" and "explain" outputs are useful as well. 3) Start a post or ticket asking for help - with that info we can see what's going on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Nathan [ 2022 Aug 03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thank you for your feedback. I'll start a new post with all the info. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Péter Láng [ 2022 Nov 04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I think this issue is still very much present in version 6.0.9. My setup is much smaller (single server node, 20 hosts, 2500 items, 1100 triggers, 20 values/sec), but otherwise quite similar: I'm using Ubuntu 22.04 LTS and MariaDB 10.6.7-2ubuntu1.1. Previously I had more items (around 10K I think) and started to get slow query logs in the server:
MariaDB [zabbix]> analyze select distinct g.graphid,g.name,g.width,g.height,g.yaxismin,g.yaxismax,g.show_work_period,g.show_triggers,g.graphtype,g.show_legend,g.show_3d,g.percent_left,g.percent_right,g.ymin_type,g.ymin_itemid,g.ymax_type,g.ymax_itemid,g.discover from graphs g,graphs_items gi,items i,item_discovery id where g.graphid=gi.graphid and gi.itemid=i.itemid and i.itemid=id.itemid and id.parent_itemid=75725;
+------+-------------+-------+--------+-----------------------------------+------------------+---------+------------------------+------+----------+----------+------------+-------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra |
+------+-------------+-------+--------+-----------------------------------+------------------+---------+------------------------+------+----------+----------+------------+-------------------------------------------------+
| 1 | SIMPLE | g | ALL | PRIMARY | NULL | NULL | NULL | 1 | 4127.00 | 100.00 | 100.00 | Using temporary |
| 1 | SIMPLE | gi | ALL | graphs_items_1,graphs_items_2 | NULL | NULL | NULL | 1 | 15117.00 | 100.00 | 0.02 | Using where; Using join buffer (flat, BNL join) |
| 1 | SIMPLE | id | eq_ref | item_discovery_1,item_discovery_2 | item_discovery_1 | 16 | zabbix.gi.itemid,const | 1 | 0.00 | 100.00 | 100.00 | Using index; Distinct |
| 1 | SIMPLE | i | eq_ref | PRIMARY | PRIMARY | 8 | zabbix.gi.itemid | 1 | 1.00 | 100.00 | 100.00 | Using index; Distinct |
+------+-------------+-------+--------+-----------------------------------+------------------+---------+------------------------+------+----------+----------+------------+-------------------------------------------------+
4 rows in set (12.754 sec)
I initially fixed this by allocating more resources the the DB and dropping a ton of items, triggers and graphs created by some overly-eager templates (Docker). Analyze with the smaller dataset:
MariaDB [zabbix]> analyze select distinct g.graphid,g.name,g.width,g.height,g.yaxismin,g.yaxismax,g.show_work_period,g.show_triggers,g.graphtype,g.show_legend,g.show_3d,g.percent_left,g.percent_right,g.ymin_type,g.ymin_itemid,g.ymax_type,g.ymax_itemid,g.discover from graphs g,graphs_items gi,items i,item_discovery id where g.graphid=gi.graphid and gi.itemid=i.itemid and i.itemid=id.itemid and id.parent_itemid=75725;
+------+-------------+-------+--------+-----------------------------------+------------------+---------+-------------------+------+--------+----------+------------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra |
+------+-------------+-------+--------+-----------------------------------+------------------+---------+-------------------+------+--------+----------+------------+-----------------------+
| 1 | SIMPLE | id | ref | item_discovery_1,item_discovery_2 | item_discovery_2 | 8 | const | 37 | 37.00 | 100.00 | 100.00 | Using temporary |
| 1 | SIMPLE | gi | ref | graphs_items_1,graphs_items_2 | graphs_items_1 | 8 | zabbix.id.itemid | 1 | 0.35 | 100.00 | 100.00 | |
| 1 | SIMPLE | g | eq_ref | PRIMARY | PRIMARY | 8 | zabbix.gi.graphid | 1 | 1.00 | 100.00 | 100.00 | |
| 1 | SIMPLE | i | eq_ref | PRIMARY | PRIMARY | 8 | zabbix.id.itemid | 1 | 1.00 | 100.00 | 100.00 | Using index; Distinct |
+------+-------------+-------+--------+-----------------------------------+------------------+---------+-------------------+------+--------+----------+------------+-----------------------+
4 rows in set (0.001 sec)
So it seems the strategy is different for smaller dataset, but as new data was added the strategy went back to the one above, and the execution time started to increase once again. So I added the composite index recommended by OP (create index gp_graphs_items_i_2 on graphs_items(graphid,itemid);), results:
MariaDB [zabbix]> analyze select distinct g.graphid,g.name,g.width,g.height,g.yaxismin,g.yaxismax,g.show_work_period,g.show_triggers,g.graphtype,g.show_legend,g.show_3d,g.percent_left,g.percent_right,g.ymin_type,g.ymin_itemid,g.ymax_type,g.ymax_itemid,g.discover from graphs g,graphs_items gi,items i,item_discovery id where g.graphid=gi.graphid and gi.itemid=i.itemid and i.itemid=id.itemid and id.parent_itemid=75725;
+------+-------------+-------+--------+---------------------------------------------------+---------------------+---------+------------------------+------+---------+----------+------------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra |
+------+-------------+-------+--------+---------------------------------------------------+---------------------+---------+------------------------+------+---------+----------+------------+-----------------------+
| 1 | SIMPLE | g | ALL | PRIMARY | NULL | NULL | NULL | 1 | 1736.00 | 100.00 | 100.00 | Using temporary |
| 1 | SIMPLE | gi | ref | graphs_items_1,graphs_items_2,gp_graphs_items_i_2 | gp_graphs_items_i_2 | 8 | zabbix.g.graphid | 1 | 2.97 | 100.00 | 100.00 | Using index; Distinct |
| 1 | SIMPLE | i | eq_ref | PRIMARY | PRIMARY | 8 | zabbix.gi.itemid | 1 | 1.00 | 100.00 | 100.00 | Using index; Distinct |
| 1 | SIMPLE | id | eq_ref | item_discovery_1,item_discovery_2 | item_discovery_1 | 16 | zabbix.gi.itemid,const | 1 | 0.00 | 100.00 | 100.00 | Using index; Distinct |
+------+-------------+-------+--------+---------------------------------------------------+---------------------+---------+------------------------+------+---------+----------+------------+-----------------------+
4 rows in set (0.028 sec)
With this, all was fine, until the frontend started to be extremely slow when loading certain data (for example: Trigger overview widgets on the dashboard or the Monitoring/Hosts page): MariaDB [zabbix]> analyze SELECT DISTINCT t.triggerid,t.expression,t.description,t.value,t.priority,t.lastchange,t.flags,t.comments,t.manual_close FROM triggers t,functions f,items i WHERE i.hostid IN (10532,10533,10534,10535,10536,10537,10538,10539,10540) AND f.triggerid=t.triggerid AND f.itemid=i.itemid AND NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid AND f.itemid=i.itemid AND i.hostid=h.hostid AND (i.status<>0 OR h.status<>0)) AND t.status=0 AND t.flags IN (0,4); +------+--------------------+-------+--------+-----------------------------------------------------------+---------+---------+--------------------+------+----------+----------+------------+------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra | +------+--------------------+-------+--------+-----------------------------------------------------------+---------+---------+--------------------+------+----------+----------+------------+------------------------------+ | 1 | PRIMARY | f | ALL | functions_1,functions_2 | NULL | NULL | NULL | 1 | 12252.00 | 100.00 | 22.22 | Using where; Using temporary | | 1 | PRIMARY | i | eq_ref | PRIMARY,items_1 | PRIMARY | 8 | zabbix.f.itemid | 1 | 1.00 | 100.00 | 58.54 | Using where | | 1 | PRIMARY | t | eq_ref | PRIMARY,triggers_1 | PRIMARY | 8 | zabbix.f.triggerid | 1 | 1.00 | 49.99 | 83.50 | Using where | | 2 | DEPENDENT SUBQUERY | f | ALL | functions_1,functions_2 | NULL | NULL | NULL | 1 | 6507.38 | 100.00 | 0.02 | Using where | | 2 | DEPENDENT SUBQUERY | i | eq_ref | PRIMARY,items_1,items_3,items_4,items_5,items_6,items_7 | PRIMARY | 8 | zabbix.f.itemid | 1 | 1.00 | 100.00 | 100.00 | | | 2 | DEPENDENT SUBQUERY | h | eq_ref | PRIMARY,hosts_1,hosts_2,hosts_3,hosts_4,hosts_5,c_hosts_3 | PRIMARY | 8 | zabbix.i.hostid | 1 | 1.00 | 100.00 | 52.06 | Using where | +------+--------------------+-------+--------+-----------------------------------------------------------+---------+---------+--------------------+------+----------+----------+------------+------------------------------+ 6 rows in set (24.510 sec)
Adding a composite index on functions seems to fix this: create index gp_functions_t_i on functions(triggerid, itemid); MariaDB [zabbix]> analyze SELECT DISTINCT t.triggerid,t.expression,t.description,t.value,t.priority,t.lastchange,t.flags,t.comments,t.manual_close FROM triggers t,functions f,items i WHERE i.hostid IN (10532,10533,10534,10535,10536,10537,10538,10539,10540) AND f.triggerid=t.triggerid AND f.itemid=i.itemid AND NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid AND f.itemid=i.itemid AND i.hostid=h.hostid AND (i.status<>0 OR h.status<>0)) AND t.status=0 AND t.flags IN (0,4); +------+--------------------+-------+--------+-----------------------------------------------------------+------------------+---------+--------------------+------+----------+----------+------------+-------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra | +------+--------------------+-------+--------+-----------------------------------------------------------+------------------+---------+--------------------+------+----------+----------+------------+-------------------------------------------+ | 1 | PRIMARY | f | index | functions_1,functions_2,gp_functions_t_i | gp_functions_t_i | 16 | NULL | 1 | 12252.00 | 100.00 | 22.22 | Using where; Using index; Using temporary | | 1 | PRIMARY | i | eq_ref | PRIMARY,items_1 | PRIMARY | 8 | zabbix.f.itemid | 1 | 1.00 | 100.00 | 58.54 | Using where | | 1 | PRIMARY | t | eq_ref | PRIMARY,triggers_1 | PRIMARY | 8 | zabbix.f.triggerid | 1 | 1.00 | 49.99 | 83.50 | Using where | | 2 | DEPENDENT SUBQUERY | f | ref | functions_1,functions_2,gp_functions_t_i | gp_functions_t_i | 8 | func | 1 | 1.24 | 100.00 | 100.00 | Using index | | 2 | DEPENDENT SUBQUERY | i | eq_ref | PRIMARY,items_1,items_3,items_4,items_5,items_6,items_7 | PRIMARY | 8 | zabbix.f.itemid | 1 | 1.00 | 100.00 | 100.00 | | | 2 | DEPENDENT SUBQUERY | h | eq_ref | PRIMARY,hosts_1,hosts_2,hosts_3,hosts_4,hosts_5,c_hosts_3 | PRIMARY | 8 | zabbix.i.hostid | 1 | 1.00 | 100.00 | 67.47 | Using where | +------+--------------------+-------+--------+-----------------------------------------------------------+------------------+---------+--------------------+------+----------+----------+------------+-------------------------------------------+ 6 rows in set (0.100 sec)
So far everything seems to be running fine, however MysqlTuner still reports that there are "Joins performed without indexes", so I also think this is a broader issue, as mentioned by OP. |