Non-optimal query for getting event notification

XMLWordPrintable

    • Type: Incident report
    • Resolution: Won't fix
    • Priority: Blocker
    • None
    • Affects Version/s: 2.4.6
    • Component/s: Frontend (F)

      It does not require to use events table in the query at all:

      zabbix=# SELECT a.alertid,mt.description,u.alias,u.name,u.surname,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype
      zabbix-# FROM events e,alerts a
      zabbix-# LEFT JOIN users u ON u.userid=a.userid
      zabbix-# LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid
      zabbix-# WHERE a.eventid='38783839'
      zabbix-# AND a.status='1'
      zabbix-# AND e.eventid = a.eventid
      zabbix-# AND a.alerttype IN (0,1) ORDER BY a.alertid LIMIT 30 OFFSET 0;
      Time: 25413.063 ms
      

      AFTER removing the event table from the request :
      -----------

      zabbix=# SELECT a.alertid,mt.description,u.alias,u.name,u.surname,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype
      zabbix-# FROM alerts a
      zabbix-# LEFT JOIN users u ON u.userid=a.userid
      zabbix-# LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid
      zabbix-# WHERE a.eventid='38783839'
      zabbix-# AND a.status='1'
      zabbix-# AND a.alerttype IN (0,1) ORDER BY a.alertid LIMIT 30 OFFSET 0;
      Time: 3.416 ms
      

            Assignee:
            Unassigned
            Reporter:
            Alexey Pustovalov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: