Heavy query in latest data

XMLWordPrintable

    • Type: Problem report
    • Resolution: Duplicate
    • Priority: Major
    • None
    • Affects Version/s: 5.0.2
    • Component/s: Frontend (F)
    • None

      Steps to reproduce:

      1. Upgrade Zabbix to 5.0.2 version with PostgreSQL 11 and TimescaleDB extension with big history* tables
      2. Check latest data

      Result:

      1. Getting heavy query and slow web response

      Rootcause is SQL query

      SELECT itemid FROM history WHERE itemid IN (itemid1,itemid2,itemid3,...) GROUP BY itemid HAVING MAX(clock)>$period

      Query generated by getItemsHavingValuesFromSql function from CHistoryManager.php

      Suggested alternative:

      with cleaned as(select itemid from history where clock >$period) select distinct itemid from cleaned where itemid in((itemid1,itemid2,itemid3,...);

      Rollback to 5.0.1 Frontend version have fixed the issue

       

      Execution plan for

      current SQL

      and

      Suggested SQL

       

            Assignee:
            Unassigned
            Reporter:
            Igor Gorbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: