Hi guys,
I want to use the following SQL statement on the Zabbix database.
When i use a join to the history table (see dash) i get a problem. The query takes a long time to load (doesn't load)
I don't know the model, do you have any tips?
Thanks,
Kind regards,
André
I want to use the following SQL statement on the Zabbix database.
When i use a join to the history table (see dash) i get a problem. The query takes a long time to load (doesn't load)
I don't know the model, do you have any tips?
Code:
SELECT DISTINCT hosts.host AS RESOURCENAME, hosts.name AS RESOURCEKIND, #history.clock AS "TIMESTAMP", "host.name" AS IDENTKEY1, hosts.name AS IDENTVALUE1, "host.key" AS IDENTKEY2, hosts.hostid AS IDENTVALUE2, SUBSTRING_INDEX(items.key_, '.', -2) AS METRICNAME1, triggers.description, functions.triggerid, events.acknowledged, triggers.value, items.lastvalue FROM triggers INNER JOIN functions ON ( functions.triggerid = triggers.triggerid ) INNER JOIN items ON ( items.itemid = functions.itemid ) #INNER JOIN history ON ( items.itemid = history.itemid) INNER JOIN hosts ON ( items.hostid = hosts.hostid ) INNER JOIN events ON ( events.objectid = triggers.triggerid ) WHERE (events.eventid DIV 100000000000000) IN (0) AND (events.object-0)=0 AND (triggers.value=1 OR (triggers.value =0 AND unix_timestamp(now()) - triggers.lastchange <60)) AND hosts.status =0 AND items.status =0 AND triggers.status =0 GROUP BY functions.triggerid ORDER BY triggers.lastchange DESC limit 200
Kind regards,
André

Comment